Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

send problem



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




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org