Re: [tuxdroid-user] Small issue with tcp/ip when disconnecting the socket
Status: Beta
Brought to you by:
ks156
From: neimad <ror...@gm...> - 2007-06-21 17:19:56
|
"David Bourgeois" <da...@ja...> writes: > But looking into this, I came up with a question about this: > if ((send(tcp_clients_handle[i], data, sizeof(tcp_frame_t), 0)) =3D=3D 0) > tcp_remove_client(i); > > R=C3=A9mi got this in the past if the client was exited without telling to > the daemon, 'send' would return 0. > Looking at the man page, I can't find how send can return 0, at least > now in non blocking mode either it adds the data or it returns -1 as > an error. But in blocking mode, 0 would mean that 0 bytes have been > successfully sent. Any clarification about this? > I guess that we can change the '=3D=3D 0' into '<=3D 0' or better '< 0' if > we're sure 0 can't happen anymore in non-blocking mode. Unless I'm mistaken, in the current code the sockets are *blocking*. If send() returns < 0, we can assume the connection to the client has been closed, yes. Damien |