in reply to Restarting a script without dropping clients

One option is to create a proxy server which allows your code to drop and reopen connections which are transparently connected to the clients. Basically something like:

     server <--> proxy <--> clients

When you need to restart the server, just send the proxy a special message saying "buffer all client connections until the new server boots". Then kill the server and restart with new code. The server connects to the proxy and resumes talking to the clients who are none the wiser.

Another, much more drastic, option would be to use UDP sockets instead of TCP sockets. UDP sockets are connectionless and you can restart your server as much as you want without disturbing clients. However, UDP sockets require you to handle retransmission when packets are lost and don't guarantee ordered delievery of packets, so there's definitely a downside here.

-sam

Replies are listed 'Best First'.
Re: Re: Restarting a script without dropping clients
by MidLifeXis (Monsignor) on Dec 15, 2003 at 18:26 UTC
    Another, much more drastic, option would be to use UDP sockets instead of TCP sockets. UDP sockets are connectionless and you can restart your server as much as you want without disturbing clients. However, UDP sockets require you to handle retransmission when packets are lost and don't guarantee ordered delievery of packets, so there's definitely a downside here.

    Depending on the nature of the application, UDP can also be less secure. All you know is that someone claimed to place something in your UDP conversation. Securing UDP has a much more difficult path than TCP. I am not saying it cannot be done, you just end up writing many of the things that TCP already handles for you.

    --MidLifeXis