日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

WSARecv() 函数使用解析

發(fā)布時(shí)間:2023/12/18 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 WSARecv() 函数使用解析 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

詳情參考:https://msdn.microsoft.com/en-us/library/windows/desktop/ms741688(v=vs.85).aspx

簡述

The?WSARecv?function receives data from a connected socket or a bound connectionless socket.

The?WSARecv?function provides some additional features compared with the standard?recv?function in three important areas:

  • It can be used in conjunction with overlapped sockets to perform overlapped?recv?operations.
  • It allows multiple receive buffers to be specified making it applicable to the scatter/gather type of I/O.
  • The?lpFlags?parameter is used both on input and returned on output, allowing applications to sense the output state of the?MSG_PARTIAL?flag bit. However, the?MSG_PARTIAL?flag bit is not supported by all protocols.

WSARecv?和標(biāo)準(zhǔn)的recv相比有以下擴(kuò)展特性:

  1.可以和重疊sockets結(jié)合來使用重疊接收操作

  2.允許使用多個(gè)接收buffer來應(yīng)對(duì)分散/聚合型IO

  3.lpFlags參數(shù)可以用在輸入和輸出上,允許應(yīng)用感知輸出狀態(tài)的MSG_PARTIAL?標(biāo)志位

函數(shù)原型

int WSARecv(_In_????SOCKET ????????????????????????????s,_Inout_?LPWSABUF ??????????????????????????lpBuffers,_In_????DWORD ?????????????????????????????dwBufferCount,_Out_???LPDWORD ???????????????????????????lpNumberOfBytesRecvd,_Inout_?LPDWORD ???????????????????????????lpFlags,_In_????LPWSAOVERLAPPED ???????????????????lpOverlapped,_In_????LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine );

參數(shù)

s: 套接字句柄

lpBuffers: 與Recv函數(shù)不同 這里需要一個(gè)由WSABUF結(jié)構(gòu)構(gòu)成的數(shù)組

dwBufferCount: 數(shù)組中WSABUF結(jié)構(gòu)的數(shù)量

lpNumberOfBytesRecvd: 如果接收操作立即完成,這里會(huì)返回函數(shù)調(diào)用所接收到的字節(jié)數(shù)

lpFlags:A pointer to flags used to modify the behavior of the?WSARecv?function call. For more information, see the Remarks section.

lpOverlapped:WSAOVERLAPPED?structure

lpCompletionRoutine:?A pointer to the completion routine called when the receive operation has been completed (ignored for nonoverlapped sockets).

返回值

Error codeMeaning
WSAECONNABORTED

The virtual circuit was terminated due to a time-out or other failure.

WSAECONNRESET

For a stream socket, the virtual circuit was reset by the remote side. The application should close the socket as it is no longer usable. For a UDP datagram socket, this error would indicate that a previous send operation resulted in an ICMP "Port Unreachable" message.

WSAEDISCON

Socket?s?is message oriented and the virtual circuit was gracefully closed by the remote side.

WSAEFAULT

The?lpBuffers?parameter is not completely contained in a valid part of the user address space.

WSAEINPROGRESS

A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.

WSAEINTR

The (blocking) call was canceled by the?WSACancelBlockingCall?function.

WSAEINVAL

The socket has not been bound (for example, with?bind).

WSAEMSGSIZE

The message was too large to fit into the specified buffer and (for unreliable protocols only) any trailing portion of the message that did not fit into the buffer has been discarded.

WSAENETDOWN

The network subsystem has failed.

WSAENETRESET

For a connection-oriented socket, this error indicates that the connection has been broken due to?keep-alive?activity that detected a failure while the operation was in progress. For a datagram socket, this error indicates that the time to live has expired.

WSAENOTCONN

The socket is not connected.

WSAENOTSOCK

The descriptor is not a socket.

WSAEOPNOTSUPP

MSG_OOB?was specified, but the socket is not stream-style such as type SOCK_STREAM, OOB data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only send operations.

WSAESHUTDOWN

The socket has been shut down; it is not possible to call?WSARecv?on a socket after?shutdown?has been invoked with?how?set to?SD_RECEIVE?or?SD_BOTH.

WSAETIMEDOUT

The connection has been dropped because of a network failure or because the peer system failed to respond.

WSAEWOULDBLOCK

?

Windows?NT:??Overlapped sockets: there are too many outstanding overlapped I/O requests. Nonoverlapped sockets: The socket is marked as nonblocking and the receive operation cannot be completed immediately.

WSANOTINITIALISED

A successful?WSAStartup?call must occur before using this function.

WSA_IO_PENDING

An overlapped operation was successfully initiated and completion will be indicated at a later time.

WSA_OPERATION_ABORTED

The overlapped operation has been canceled due to the closure of the socket.

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/jasonsword/p/7531866.html

總結(jié)

以上是生活随笔為你收集整理的WSARecv() 函数使用解析的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。