send返回成功是否意味着数据送到对方机器?

kingstarer 2011-02-27 10:38:50
不考虑应用层接收 send成功是否意味着数据已送达对方机器(即tcp传输成功)?

如果不是 那send成功意味着什么? 消息已送达系统发送缓冲区吗?

如果是 怎么验证?
...全文
109 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
qman007 2011-03-09
  • 打赏
  • 举报
回复
这里有两个条件,
一:如果通过setsockopt()设置发送缓存为0的话,则
send()会以阻塞调用的方式将数据发送给对等方,
其返回值就是对等方协议栈入栈字节长度。(你可以通过插拔网线模拟)
二: 如果没有设置发送缓存为0的话,则send()也会以
阻塞调用的方式把药发送的数据按长度追加到发送缓
存尾部,其返回值是实际追加拷贝的字节数。
如果此时发送缓存已满,则send会阻塞。
太乙 2011-02-27
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/en-us/library/ms740149(v=vs.85).aspx
太乙 2011-02-27
  • 打赏
  • 举报
回复
If no buffer space is available within the transport system to hold the data to be transmitted, send will block unless the socket has been placed in nonblocking mode. On nonblocking stream oriented sockets, the number of bytes written can be between 1 and the requested length, depending on buffer availability on both the client and server computers. The select, WSAAsyncSelect or WSAEventSelect functions can be used to determine when it is possible to send more data.
太乙 2011-02-27
  • 打赏
  • 举报
回复
The successful completion of a send function does not indicate that the data was successfully delivered and received to the recipient. This function only indicates the data was successfully sent.
昵称很不好取 2011-02-27
  • 打赏
  • 举报
回复
The send function is used to write outgoing data on a connected socket. For message-oriented sockets, care must be taken not to exceed the maximum packet size of the underlying provider, which can be obtained by using getsockopt to retrieve the value of socket option SO_MAX_MSG_SIZE. If the data is too long to pass atomically through the underlying protocol, the error WSAEMSGSIZE is returned, and no data is transmitted.

The successful completion of a send does not indicate that the data was successfully delivered.
arong1234 2011-02-27
  • 打赏
  • 举报
回复
tcp,是的,已经发送到对方
udp,不是

3,882

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧