C/C++ socket send causes program to exit
- From: Bjorn Nuyttens <cybercake@xxxxxxxxxx>
- Date: Mon, 16 Jul 2007 16:12:11 GMT
I have two programs, a "client" and a "server". The server just sends
some data to the client. When I kill the client by pressing Ctrl+C, the
connection is not always properly terminated on the server's side.
When the server is in the middle of a send() or write() call, the
process exists with error code 141. No Segmentation faults, no
exceptions thrown, not even a return value from the send/write call. I
expect send or write to return -1 (see manpages) but it does not return,
the whole process just exits.
Any ideas what could be causing this? Can this be caused by a bug in the
OS (Ubuntu 7.04)?
Program code:
printf("1"); fflush(stdout);
//int retval = send(s, pData, uLength, 0);
int retval = write(s, pData, uLength);
printf("2"); fflush(stdout);
Typical output at the server side:
121212121212 (kill client)(server exits correctly with code 0)
12121212121 (kill client when server calls send)(server stops executing
code, i.e. printf etc and process exits with code 141)
Bjorn Nuyttens
.
- Follow-Ups:
- Re: C/C++ socket send causes program to exit
- From: David Schwartz
- Re: C/C++ socket send causes program to exit
- Prev by Date: Re: Raw ethernet socket
- Next by Date: odd network traffic?
- Previous by thread: 1000 IP packets with different SOURCE&DESTINATION addresses generator/simulator
- Next by thread: Re: C/C++ socket send causes program to exit
- Index(es):
Relevant Pages
|