[CentOS] socket: write vs send

Tue Apr 6 20:57:28 UTC 2010
Les Mikesell <lesmikesell at gmail.com>

On 4/6/2010 3:41 PM, m.roth at 5-cent.us wrote:
>> On Tue, 06 Apr 2010 14:53:45 -0500, Les Mikesell wrote:
>> [...]
>>> They should be equivalent - if the other end closes first, you'll get a
>>> SIGPIPE, which by default will kill the process.  If you want to keep
>>> running you have to handle or ignore the signal.
>> How about if I use MSG_NOSIGNAL in the flags argument?
> I don't think I'd do that. Rather, trap only the ones you expect (for
> testing *ONLY*), then have it let you know of any other errors handed it.
> But don't just let it crash. Consider that other errors might be coming
> (SEGV, say).

Or, depending on the kind of service this is supposed to provide you 
might let xinetd start an instance for every connection (like telnet, 
etc). Your code can be much simpler that way since exiting on anything 
unexpected is then the right thing to do.

   Les Mikesell
    lesmikesell at gmail.com