send problem
Patrick R. McManus
mcmanus at ducksong.com
Tue May 28 16:45:33 EDT 2002
either add this:
signal (SIGPIPE,SIG_IGN);
or add MSG_NOSIGNAL to your send() flags.
then send() will return with <1 in step 3 and an errno of EPIPE for
you.
-P
[FRamsay at castelhq.com: Tue, May 28, 2002 at 04:37:33PM -0400]
> I'm having a really wierd problem with a bit of C code
>
> I have an array of socket file descriptors that is looped though and
> messages sent to. If one of the remote applications dies it causes a
> broken pipe in the application...
>
> I'll try and illistrate the problem.
>
> step 1)
> when the client is working the network connections look like this:
> server<=ESTABLISHED=client
> server=ESTABLISHED=>client
> Everything works perfectly and send returns the number of bytes written as
> expected.
>
> step 2)
> But when the client dies the network switches to this:
> server<=FIN_WAIT2 = client
> server =CLOSE_WAIT=>client
> But when you send data from the server it _still_ return the number of
> bytes in the message as if it was a good connection. ie if I sent
> "Linux\0" it would return 6. I was assuming that because the client is
> dead that send would fail and return send's error code (-1) but it doesn't.
> And errno doesn't seem to have anything usefull in it either :(
>
> When the send has happened however the connection finally goes away.
>
> step 3)
> If it tries another send the program just gets a "Broken pipe" error
> (inside send) and dies (with no core thank you very much) Now I know why
> the broken pipe is occuring... there is no connection to send across. but I
> would think I should also get an error code returned here... but no.
>
> So does anyone have any idea why am I not getting an error code at either
> step 2 or 3?
>
> -fjr
>
>
>
>
>
> _______________________________________________
> Discuss mailing list
> Discuss at blu.org
> http://www.blu.org/mailman/listinfo/discuss
More information about the Discuss
mailing list