初学!请问WSASEND和SEND有什么区别和联系?

rabolee 2003-08-11 11:08:44
如题
...全文
359 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
fanqing 2003-09-04
  • 打赏
  • 举报
回复
up
rabolee 2003-09-04
  • 打赏
  • 举报
回复
顶死!
rabolee 2003-09-04
  • 打赏
  • 举报
回复
我在弄一个程序。我发现接收用了两个函数。WSARecv和Recv。
每一个同样的消息。都会先用WSARecv收一次,再用Recv收一次。
一般其他的程序都只有一个Recv。它这样做有什么用呢。讲讲?
zhanshenpkl 2003-09-01
  • 打赏
  • 举报
回复
The WSASend function is used to write outgoing data from one or more buffers on a connection-oriented socket specified by s. It can also be used, however, on connectionless sockets that have a stipulated default peer address established through the connect or WSAConnect function.

For overlapped sockets (created using WSASocket with flag WSA_FLAG_OVERLAPPED) sending information uses overlapped I/O, unless both lpOverlapped and lpCompletionRoutine are NULL. In that case, the socket is treated as a nonoverlapped socket. A completion indication will occur, invoking the completion of a routine or setting of an event object, when the buffer(s) have been consumed by the transport. If the operation does not complete immediately, the final completion status is retrieved through the completion routine or WSAGetOverlappedResult.

If both lpOverlapped and lpCompletionRoutine are NULL, the socket in this function will be treated as a nonoverlapped socket.

For nonoverlapped sockets, the last two parameters (lpOverlapped, lpCompletionRoutine) are ignored and WSASend adopts the same blocking semantics as send. Data is copied from the buffer(s) into the transport's buffer. If the socket is nonblocking and stream oriented, and there is not sufficient space in the transport's buffer, WSASend will return with only part of the application's buffers having been consumed. Given the same buffer situation and a blocking socket, WSASend will block until all of the application's buffer contents have been consumed
zhanshenpkl 2003-09-01
  • 打赏
  • 举报
回复
The WSASend function provides functionality over and above the standard send function in two important areas:

It can be used in conjunction with overlapped sockets to perform overlapped send operations.
It allows multiple send buffers to be specified making it applicable to the scatter/gather type of I/O.
rabolee 2003-08-29
  • 打赏
  • 举报
回复
哦?怎么越讲越复杂!

一个程序里面两种函数都有,怎么解释?
livelivelive 2003-08-15
  • 打赏
  • 举报
回复
WSA版本的支持重叠IO机制,允许你调用后马上返回,当数据发送后能自动调用你设定的重叠处理函数。
feeboby 2003-08-11
  • 打赏
  • 举报
回复
前者是后者的实现。
zhouyong0371 2003-08-11
  • 打赏
  • 举报
回复
一个是非阻塞,一个是阻塞,但是Send好像也会立即返回。
netfyee 2003-08-11
  • 打赏
  • 举报
回复
异步发送(非阻塞),和非异步发送啊(阻塞)

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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