C/C++ socket send causes program to exit



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
.



Relevant Pages

  • Re: Kill TCP session
    ... kill is used to kill process. ... How it's possible to kill a tcp session btw client and solaris server ... i have some tcp connexion to the application running on my solaris ...
    (comp.unix.solaris)
  • passing Safearray to VB
    ... I try to pass an array of BSTR to a VB client. ... exits, I get a Firstchance Exception in the Server. ... Dim Experiment As NIRExperiment ...
    (microsoft.public.vc.language)
  • passing Safearray to VB
    ... I try to pass an array of BSTR to a VB client. ... exits, I get a Firstchance Exception in the Server. ... Dim Experiment As NIRExperiment ...
    (microsoft.public.vc.atl)
  • Re: I need a tip for socket disconnection issue.
    ... 'Kill the socket. ... 'Kill any data being sent or received. ... I have a server that handle many client connection. ... In the case that the server try to send a message to a client. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: I need a tip for socket disconnection issue.
    ... 'Kill the socket. ... 'Kill any data being sent or received. ... I have a server that handle many client connection. ... In the case that the server try to send a message to a client. ...
    (microsoft.public.dotnet.languages.vb)