write() udp socket

3 messages, 3 authors, 2011-07-25 · open the first message on its own page

write() udp socket

From: ZHOU Xiaobo <hidden>
Date: 2011-07-23 09:30:47

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'?


question No2:
Can I write() a UDP socket in multiple threads without locking?


thanks


------------------
Sincerely yours
                         ZHOU Xiaobo

Re: write() udp socket

From: Huajun Li <hidden>
Date: 2011-07-24 08:33:11

2011/7/23 ZHOU Xiaobo [off-list ref]:
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.
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.
thanks


------------------
Sincerely yours
                        ZHOU Xiaobo

Re: write() udp socket

From: Rick Jones <hidden>
Date: 2011-07-25 17:38:13

On 07/24/2011 01:33 AM, Huajun Li wrote:
2011/7/23 ZHOU Xiaobo[off-list ref]:
quoted
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.
I believe it should either appaear to succeed or fail.  write() best not 
be sending partial UDP datagrams.  That would be "bad."
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help