Tip, try keeping repetitions to a minimum even if it means slightly more code by text size. This makes it easier to change things later and to pull out common functionality into a function.
Here:

    var serverPlugins;
    if (global.serverPluginsRequired)
        serverPlugins = "*";
    else
        serverPlugins = "";
    serverPlugins += global.serverPluginList;
    write_ubyte(socket, string_length(serverPlugins);
    write_string(socket, serverPlugins);

Small details but eh.