【发布时间】:2009-03-19 10:06:05
【问题描述】:
我对使用阻塞套接字时发送函数的行为感兴趣。
手册没有明确说明此案例。
从我的测试(和文档)来看,当在阻塞套接字上使用 send 时,我有两种情况:
- 所有数据都发送完毕
- 返回错误,不发送任何内容
在代码行中(例如在 C 中),翻译如下:
// everything is allocated and initilized
int socket_fd;
char *buffer;
size_t buffer_len;
ssize_t nret;
nret = send(socket_fd, buffer, buffer_len, 0);
if(nret < 0)
{
// error - nothing was sent (at least we cannot assume anything)
}
else
{
// in case of blocking socket everything is sent (buffer_len == nret)
}
我说的对吗?
我对所有平台(Windows、Linux、*nix)上的这种行为感兴趣。
【问题讨论】:
标签: windows linux unix sockets