Re: More Specific Broken Pipe Error
- Posted by cense <cense at MAIL.RU> Nov 14, 2000
- 411 views
On Tue, 14 Nov 2000, Kayhlan wrote: heya again, >> Ok. I have been at it all day and have narrowed down the possibilities. >> Perhaps someone out there can read this little example and may know why I >> am getting the Broken Pipe error. >> The following routine works flawlessly with connected sockets. The pipe crash >> happens when >> someone severs a link to the server by simply shutting off their client (a >> generic MUD client) >> and this routine tries to send information. However, the crash does not >> happen in every >> instance of this. If i understand what you are trying to say is that when someone closes their client by quiting it, then the error has a possibility of occuring. >> Most of the time poll () is able to pick up the disconnect and I >> automatically shut them down. >> In every instance, the person who is connected to the socket simply shut down >> without entering >> any information. Therefore, I think I can assume that it is not a problem of >> buffered >> information still waiting to be read because they reported little to no lag >> before >> disconnecting. The code is as follows: >> >> game_output_buffer = allocate(length(text)) >> poke(game_output_buffer, text) >> xxx = c_func(write, {n, game_output_buffer, length(text)}) >> free(game_output_buffer) >> >> n is the file descriptor >> game_output_buffer and xxx are atoms >> >> I have yet to record xxx being -1 and in all the man pages it tells of write >> returning a SIGTRM >> on error. I hope this helps to describe the problem I am having a bit >> better. If anymore is >> needed please let me know and I will provide it. Again, I will appreciate any >> feedback on this >> as I have searched fruitlessly for the past 14 or so hours for the problem >> and/or it's >> solution, but so far with no success on either. I would have figured the same as you in the situation, that write( ) would have returned an error code if it could not send data. Usually as described by the man file, if a file/socket descriptor was invalid -1 would be returned and errno set properly. But obviously this is not the case. Where in the man page did you see anything about SIGTERM? I could not see it. If your process getting the SIGTERM signal would explain everything because SIGTERM is the TERMINATION signal. When a process gets this signal is *usually* terminates hence the "broken pipe error" A solution might be to "catch" the shutting down of the client and properly disconnect the socket before any damage is done. On another note, I really do think that you should be using send( ) and recv( ) instead of write( ) and read( ). send and recv were designed for sockets specifically while read and write were not. This is my only suggestion as i have no other thoughts on solutions at this moment. Hope some of my bullsh*t might help you. -- evil, corruption and bad taste ^[cense]