Socket State Before Call To Send()?

Socket State Before Call To Send()?

Post by Shane McDa » Fri, 04 Jul 2003 02:42:35


I am having troublee determining if a socket is still connected to the
remote host before I make a call to send().

I know how to determine this in my code that makes the call to read(),
ie check if read() returns 0, but the code that does the read() does not
have access to certain variables I need to unset when the socket has
been terminated by the other side.

What I need to be able to do is to simply determine if a socket is still
connected to it's remote host without using a read() call, as the read
code is being done elsewhere and I don't want to mess up the actual
read()) call.

-shane
 
 
 

Socket State Before Call To Send()?

Post by Lorinczy Z » Fri, 04 Jul 2003 02:56:18

just call write, it will return -1 and errno will contain ECONNRESET, EPIPE
or similar... and disable beforehand SIGPIPE...