cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl multi interface - handling abnormal disconnections

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 28 Jan 2014 16:15:42 +0100 (CET)

On Tue, 28 Jan 2014, Jonathan Masters wrote:

> - Calls ssize_t result = send(fd,0,0,0), if result == -1, assume
> disconnected, if so send a message and remove the connection from the cache.

That's not very portable. As the man page for send(2) says on my Linux: "No
indication of failure to deliver is implicit in a send().".

... and then I don't even think there's a guarantee that sending 0 bytes would
even do the check you want.

I would rather suggest you instead check if the socket is readable, as closed
sockets become readable. That's also why we do it that way in libcurl already
(lib/url.c:SocketIsDead).

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2014-01-28