[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tencent_7BA0E68E7426BCE073E1835B@qq.com>
Date: Tue, 26 Jul 2011 13:39:33 +0800
From: "ZHOU Xiaobo" <xb.zhou@...com>
To: "Huajun Li" <huajun.li.lee@...il.com>
Cc: "netdev" <netdev@...r.kernel.org>
Subject: Re: write() udp socket
------------------
Sincerely yours
ZHOU Xiaobo
------------------ Original ------------------
From: "Huajun Li"<huajun.li.lee@...il.com>;
Date: Sun, Jul 24, 2011 04:33 PM
To: "ZHOU Xiaobo"<xb.zhou@...com>;
Cc: "netdev"<netdev@...r.kernel.org>;
Subject: Re: write() udp socket
2011/7/23 ZHOU Xiaobo <xb.zhou@...com>:
> question No1:
> When I call
> ssize_t write(int fd, const void *buf, size_t count);
>
>
> on a nonblocking UDP socket, is the return value always equal to 'count'?
>
>
I don't think so. The function may be interrupt by signal or return
due to other reason, so the return value only represents the size it
writes successfully to the fd.
UDP is datagram, so I think it guarantees the 'buffer' in 'write()' is entirely sent
like an atomic operate.
> question No2:
> Can I write() a UDP socket in multiple threads without locking?
>
In my opinion, you could. However, the receiver may not get what you expected.
what will happen? I only concern whether the application 'buffer' is sent partially which
is unacceptable.
>
> thanks
>
>
> ------------------
> Sincerely yours
> ZHOU Xiaobo
Powered by blists - more mailing lists