lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Quoth Valerio Schiavoni <valerio.schiavoni@gmail.com>, on 2011-01-17 18:43:58 +0100:
> What I try to do is as simple as this:
> - establish a tcp connection between 2 machines
> - as soon as the server crashes and the connection is somehow broken,
> the client must do something

You can't do that.  There is no way to detect that on the wire if you
really want "as soon as"; the only thing you'd detect is the absence
of packets, and there has to be a delay, otherwise a little bit of lag
will be treated as a closed connection.  If I unplug a network cable
in the middle, this is indistinguishable from any other silent period.

> I say 'crashes' because no assumptions are made on the server-side:
> there are no calls to 'server:close()' or 'server:shutdown()'

TCP-level keepalives are not readily configurable at the application
level in many common operating systems.  There is no standard socket
option that I know of to set the timing from that side; I've only ever
seen it done at the OS configuration level.

I wouldn't use them if there's another choice.  If you're designing
the application protocol, provide a mechanism for application-level
keepalives instead.  If you're not designing the application protocol,
you may be hosed (but then what are you doing demanding immediate
notification of connection disruption anyway?).

   ---> Drake Wilson