write() udp socket
Subsystems (2)
question No1:
When I callssize_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
2011/7/23 ZHOU Xiaobo <[email protected]>:
Quoted 8 lines
question No1:
When I callssize_twrite(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.
Quoted 3 lines
question No2:
Can Iwrite()a UDP socket in multiple threads without locking?
In my opinion, you could. However, the receiver may not get what you expected.
Quoted 7 lines
thanks
------------------
Sincerely yours
ZHOU Xiaobo
Quoted 6 lines · Huajun Li
2011/7/23 ZHOU Xiaobo<[email protected]>:
Quoted 5 lines
question No1:
When I callssize_twrite(int fd, const void *buf, size_t count);
Quoted 7 lines
Quoted 3 lines
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."