How to detect a socket connection broken when sending a message on Solaris

How to detect a socket connection broken when sending a message on Solaris

Post by Chuck Zhen » Mon, 05 May 1997 04:00:00



Hi all,

On Solaris 2.5, I use socket to write a server and a client. (At present
the server simply just echo all the data sent by the client back to the
client.

When the client send a message, I want to know whether it is successful -
I setup signal handler for SIGPIPE.  The problem is, if the server goes
down (say kill -9), the client did not get SIGPIPE on next send but gets
it on the send after the next.  e.g.:

client

--
Actrix Networks Limited                  Internet Service Providers.

 
 
 

How to detect a socket connection broken when sending a message on Solaris

Post by Andrew Giert » Mon, 05 May 1997 04:00:00


 Chuck> When the client send a message, I want to know whether it is
 Chuck> successful - I setup signal handler for SIGPIPE.  The problem
 Chuck> is, if the server goes down (say kill -9), the client did not
 Chuck> get SIGPIPE on next send but gets it on the send after the
 Chuck> next.  e.g.:

That's unavoidable.


database, (Subject: TCP problem), for an explanation.

In any case, the success of a write() call is never an indication of
successful receipt by the other process; however, TCP does guarantee
that data written will either be delivered, or the connection aborted.
It's up to you to work out what to do in the latter case.

--
Andrew.

comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>

 
 
 

1. How to detect broken socket connection when sending message

Hi all,

On solaris 2.5, I used socket to wrote a server and a client.  I want to
know whether a send from client to server is successful (without server
program send back an Ack msg by user).  I installed a signal handler for
SIGPIPE, which man page said you will get when connection is broken when
write().

The problem is that if the server is down (say kill -9), the client does
not get a SIGPIPE on next send, but gets one on the one after.  e.g.

client                       server
send                         /* fine */
send                         /* find */
                             -- server dies
send (no SIGPIPE)
send - gets a SIGPIPE.

I have also tried setsockopt(... SO_KEEPALIVE .. ), but it does not seem
to make any difference.

One interesting thing to know is that if I port the server to Windows
NT/WIN32 socket, and run the server on NT.  the client does get SIGPIPE on
the next send after connection is broken.

Can someone tell me why?

Also, what is normal approach to detect whether current connection is
still alive?   I tried recv(... PEEK ...) and get mixed result

cheers
chuck

--
Actrix Networks Limited                  Internet Service Providers.

2. FORK command - can any UNIX guru help?!

3. Detecting a broken (socket) connection before write()

4. IEEE-488 / GPIB Driver for Linux

5. Sockets: how to detect a broken connection?

6. how to add "xhost +" automatically

7. How do I best detect abruptly broken socket connections?

8. 2.4.2-ac18 and lvm_0.9

9. how to detect a broken socket connection?

10. SO_KEEPALIVE - How to detect a broken socket connection without read/write?

11. detecting if a blocking socket is recieving or sending information ?

12. Opening a socket connection while in a socket connection.

13. Maximising the speed at which "broken" sockets are detected