Operating System - HP-UX
1833491 Members
2701 Online
110052 Solutions
New Discussion

Errors : SIGPIPE , Connection Reset by Peer

 
Jalaiah M
New Member

Errors : SIGPIPE , Connection Reset by Peer

OS : HP-UX

I have received a "Connection reset by peer" error while reading from a socket and "SIGPIPE" while writing to a socket. I have given shutdown(sockfd,SHUT_RDWR) in my prototype to simulate the error.

In my realtime application i have ignored the SIGHUP signal. Even then I receive the "Connection reset by peer" and "SIGPIPE" errors. Can anyone help me to figure out how the socket is disabled for read and write?
4 REPLIES 4
Ronaldinho
Advisor

Re: Errors : SIGPIPE , Connection Reset by Peer

Hi Jaliah,
Socket information can be found in /etc/services

what socket are you using?

Laurent Menase
Honored Contributor

Re: Errors : SIGPIPE , Connection Reset by Peer

Hi Jalaiah,
Usually it happens when the peer had reset the connection.
You can reproduce it with an application which set the abortive linger option - look at setsockopt(2)-(linger.l_onoff=1 linger.l_linger=0)
When you then close that socket a reset is send in place of a FIN.


Else you can try tcp_discon_by_addr.

This may happen if the connectivity is lost too.

Jalaiah M
New Member

Re: Errors : SIGPIPE , Connection Reset by Peer

Hi Ronaldinho,

Socket used is : TCP/IP.

In realtime application, "shutdown()" is not called in any case. Is there any ways the OS-Kernel decides to shutdown the socket for read/write automatically in raise of any other events? If OS makes it, then is it logged anywhere?
Laurent Menase
Honored Contributor

Re: Errors : SIGPIPE , Connection Reset by Peer

There is 3 way to have a connection being reset:
1) the peer system is using the linger option which makes that close cause a reset
2) a ndd tcp_discon or tcp_discon_byaddr
3) the connectivity with the peer system had been lost, and there are still messages unacked after a timeout. then the connection get reset and cause that sequence.

for instance:
write(mysocket,..)
we loose connectivity
after some retransmitions, the connection is reset causing the connection to be reset.
Then the read return an error with connection reset by peer error, and then any write cause a SIGPIPE except if it is ignored, then write() return an error with EPIPE.

Else I don't see.