Re: socket issue on linux c program
- From: "Alex Fraser" <me@xxxxxxxxxxx>
- Date: Fri, 30 Jun 2006 16:39:15 +0100
"ed" <ed@xxxxxxxxxxx> wrote in message
news:20060629213714.3473943d@xxxxxxxxxxxxxxxxxxxxxxxx
[snip]
When my TCP socket server runs it creates a thread per connection,
which is simple enough and works ok. However, when the TCP client
leaves without shutting down the connection by telling the server to
close, the program just dies. It seems I cannot capture this error.
After an strace I saw the following:
accept(3, 0xbff70c90, [16]) = ? ERESTARTSYS (To be
restarted)
+++ killed by SIGPIPE +++
By default, SIGPIPE is raised when you call write()/send() on a connection
that logically cannot be written to (eg because the connection has been
reset). The same as calling write() on a pipe with no readers.
I suggest you call sigaction() (or signal()) to ignore SIGPIPE during
initialisation of your server. Then, in the same situation, you will get
EPIPE or some other error where you write to the socket concerned instead.
Of course, you need to check every call for errors - but you should be doing
that in any case.
Alex
.
- References:
- socket issue on linux c program
- From: ed
- socket issue on linux c program
- Prev by Date: Re: High-Speed TCP/IP Message Logging
- Next by Date: Re: Recognize a POSIX environment
- Previous by thread: Re: socket issue on linux c program
- Next by thread: multiple targets in makefile Stop.
- Index(es):
Relevant Pages
|