Re: socket: write vs send

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



On 4/6/2010 2:48 PM, Michael D. Berger wrote:
> On Tue, 06 Apr 2010 14:37:27 -0500, Les Mikesell wrote:
>
>> On 4/6/2010 2:16 PM, Michael D. Berger wrote:
>>> On CentOS 5.4,
>>> Linux 2.6.18-164.6.1.el5 #1 SMP Tue Nov 3 16:18:27 EST 2009
>>>      i686 i686 i386 GNU/Linux
>>>
>>> In man 2 send I find:
>>>
>>>     The  send()  call  may  be  used only when the socket is in a
>>>     connected state (so that the intended recipient is known).  The
>>>     only  difference between  send()  and write() is the presence of
>>>     flags.  With zero flags parameter,    send()    is    equivalent
>>>     to     write().
>>>
>>> In some complex server software, if the client disconnects:
>>>       send: delivers errno == ECONNRESET
>>> but
>>>       write: crashes the server process.
>>>
>>> So it is not really equivalent.  Any thoughts on this?
>>
>> Are you sure it isn't the normal signal associated with a write when the
>> other end closes first that is crashing the process?
>
> No, I.m not sure.  I found that send also sometimes crashes it.
> Sorry for the misleading comment.

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.

-- 
   Les Mikesell
    lesmikesell@xxxxxxxxx

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux