When will my application receive SIGPIPE?



When will my application receive SIGPIPE?..

Answer / chaitanya

Very simple: with TCP you get SIGPIPE if your end of the connection has received an RST from the other end. What this also means is that if you were using select instead of write, the select would have indicated the socket as being readable, since the RST is there for you to read (read will return an error with errno set to ECONNRESET).

Basically an RST is TCP's response to some packet that it doesn't expect and has no other way of dealing with. A common case is when the peer closes the connection (sending you a FIN) but you ignore it because you're writing and not reading. (You should be using select.) So you write to a connection that has been closed by the other end and the oether end's TCP responds with an RST.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Unix Socket Programming Interview Questions

How can I find the full hostname (FQDN) of the system I am running on?

1 Answers  


How can I put a timeout on connect()?

1 Answers  


What is a socket connection?

0 Answers  


How do I send [this] over a socket?

1 Answers  


What is the difference between read() and recv()?

0 Answers  






What exactly does SO_REUSEADDR do?

1 Answers  


How come only the first part of my datagram is getting through?

1 Answers  


What are socket exceptions? What is out-of-band data?

1 Answers  


What is a socket address?

0 Answers  


Why sockets are used?

0 Answers  


Why do I get EPROTO from read()?

0 Answers  


What is the difference between a socket and a port?

0 Answers  


Categories