Reputation: 21
In the server part, how could i detect that an allready connected client(TCP stream) has just disconnect?
Upvotes: 0
Views: 2114
Reputation: 21
@MSalters, I finally found the answer. The libuv callback function of "uv_read_start" does not return 0 (nread != 0) when the connexion is closed, it returns UV_EOF. In my configuration UV_EOF is -4095. The disconnection happens when nread == UV_EOF. I think it is possible to make a posix read on the FD associated to the handle, but this is not pretty at all (and much more complicated because the IOs are asynchronous...).
Upvotes: 1