WSARecv() 函數使用解析

詳情參考: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?和標準的recv相比有以下擴展特性:

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

  2.允許使用多個接收buffer來應對分散/聚合型IO

  3.lpFlags參數可以用在輸入和輸出上,允許應用感知輸出狀態的MSG_PARTIAL?標志位

函數原型

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
);

參數

s: 套接字句柄

lpBuffers: 與Recv函數不同 這里需要一個由WSABUF結構構成的數組

dwBufferCount: 數組中WSABUF結構的數量

lpNumberOfBytesRecvd: 如果接收操作立即完成,這里會返回函數調用所接收到的字節數

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.

?

?

轉載于:https://www.cnblogs.com/jasonsword/p/7531866.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/454647.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/454647.shtml
英文地址,請注明出處:http://en.pswp.cn/news/454647.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

獲取 docker 容器(container)的 ip 地址

獲取單個IP docker inspect --format {{ .NetworkSettings.IPAddress }} <container-ID> 獲取所有容器IP docker inspect -f {{.Name}} - {{.NetworkSettings.IPAddress }} $(docker ps -aq)轉載于:https://www.cnblogs.com/Tempted/p/7774789.html

山西臺達plc可編程控制器_可編程控制器2(PLC)控制原理

采用繼電器控制采用PC控制PC的控制原理(繼電器PC控制)a)當SB1按下&#xff0c;輸入繼電器00000的線圈通電&#xff0c;00000的常開觸點閉合&#xff0c;使得輸出繼電器01000的線圈得電&#xff0c;01000對應的硬輸出觸電閉合&#xff0c;KM1得電M1開始運轉&#xff0c;同時0100…

一篇讀懂 可轉債

可轉債興起的原因 可轉債是1992年底開始進入中國證券市場的&#xff0c;到現在已經27個年頭了。可以說&#xff0c;以前可轉債在中國證券市場一直不是市場的焦點和幸運兒&#xff0c;始終沒能成為一個上規模的可配置的投資品種——其原因很簡單&#xff0c;因為相對而言企業發…

bodhi linux 安裝 ubuntu軟件,Bodhi Linux 5.1.0 發布,基于Ubuntu的輕量級發行版

Bodhi Linux是基于Ubuntu的輕量級發行版&#xff0c;具有Moksha桌面環境。現在有很多Linux發行版。有些是獨特的&#xff0c;但很多是重復的&#xff0c;可能沒有存在的必要。由于使用了Moksha桌面環境&#xff0c;一個基于Linux的操作系統Bodhi脫穎而出。如果你不熟悉Bodhi&am…

談一談周公所理解的面試

因為公司最近招聘的力度很大&#xff0c;所以最近公司的面試很多&#xff0c;加之很多同事項目緊&#xff0c;所以讓我參加了一些技術面試。不論是作為面試官還是應聘者&#xff0c;參加工作以來我參與的面試的次數我自己也記不清了&#xff0c;所以在此想從面試官和應聘者的角…

idc機房運維巡檢_智和信通賦能國產信創 建設IT智能監控運維體系 - 蔚穎willing...

作為信創領域深耕多年的企業&#xff0c;北京智和信通技術有限公司始終堅持研發自主知識產權的IT智能運維監控大數據分析系統——智和網管平臺SugarNMS&#xff0c;積極探索AIOps智能運維&#xff0c;通過“國產安全監控分析安管日志運維開發”七合一模式&#xff0c;賦能IDC數…

long long or int

long long or int 很多時候long long爆空間&#xff0c;int有時又不夠 。 在算乘法的時候&#xff0c;要保證乘出來的中間項也不爆long long 轉載于:https://www.cnblogs.com/war1111/p/7532412.html

用Python的Tultle模塊創建一個五角星

方案所需準備Python官方手冊。 這里是我找到的中文版。一個可執行Python的解釋器Ttultle簡介來源烏龜圖形是一個不錯的方式來為孩子們介紹編程。它是Wally Feurzig和Seymour Papert在1966年開發的原始Logo編程語言的一部分。想象一只在x-y平面上&#xff0c;從&#xff08;0,0&…

鏡像上傳到linux失敗,Docker push鏡像失敗解決方法

Docker push鏡像失敗解決方法發布時間&#xff1a;2017-03-09 12:07來源&#xff1a;互聯網當前欄目&#xff1a;web技術類Docker push鏡像失敗的問題。以下是輸入push自己的tomcat后出現了失敗[rootslave3 ~]# docker push lekkoliu/tomcat8:latestThe push refers to a repos…

Python 之 Python2 和 Python3 的區別

1、默認編碼方式 # Python2 默認編碼方式是 ascll碼 # Python3 默認編碼方式是 utf-8 # Python2 輸出中文要加 # -*- encoding:utf-8 -*- # Python3 不需要 2、print # Python2 可以使用 print&#xff0c;也可以使用 print() 例&#xff1a; print(lili) 或 print lili # Py…

【C/C++開發】C++11 并發指南二(std::thread 詳解)

上一篇博客《C11 并發指南一(C11 多線程初探)》中只是提到了 std::thread 的基本用法&#xff0c;并給出了一個最簡單的例子&#xff0c;本文將稍微詳細地介紹 std::thread 的用法。 std::thread 在 <thread> 頭文件中聲明&#xff0c;因此使用 std::thread 時需要包含 &…

【找工作資料】外企面試技巧

這里談談面試的技巧。這是根據誠迅聯豐咨詢公司許國慶在北大光華管理學院、經濟學院和清華經濟管理學院的講座整理出來的。他曾在美國的投資銀行和商業銀行工作了近十年。 一、面試前的準備 1&#xff0e;確定3W 明確面試前的三要素&#xff0d;When (時間)、Where&#xf…

觸摸屏Sensor疊構實例學習記錄(一)

現在從事TP這個行業&#xff0c;看再多的資料和介紹&#xff0c;不如直接拿個實例的工程圖來看&#xff0c;分析每一部分具體是什么東西&#xff0c;比看再多的資料更容易入門。 以下圖紙和圖片都是我從網上隨便下的&#xff0c;僅次于學習記錄使用&#xff0c;不做另外的商業用…

linux查找influx的安裝位置,InfluxDB學習之InfluxDB的安裝和簡介 | Linux大學

最近用到了 InfluxDB&#xff0c;在此記錄下學習過程&#xff0c;同時也希望能夠幫助到其他學習的同學。本文主要介紹InfluxDB的功能特點以及influxDB的安裝過程。更多InfluxDB詳細教程請看&#xff1a;InfluxDB系列學習教程目錄一、InfluxDB 簡介InfluxDB 是用Go語言編寫的一個…

Python 之數據類型

文章收集于網絡&#xff0c;如有版權&#xff0c;請聯系作者 一、引子 1 什么是數據&#xff1f; x10&#xff0c;10是我們要存儲的數據 2 為何數據要分不同的類型 數據是用來表示狀態的&#xff0c;不同的狀態就應該用不同的類型的數據去表示 3 數據類型 數字、字符串、列表…

Jquery中$(document).ready(function(){ })函數的使用詳解

Jquery是優秀的Javascrīpt框架,$是jquery庫的申明&#xff0c;它很不穩定&#xff08;我就常遇上&#xff09;,換一種穩定的寫法jQuery.noConflict(); jQuery(document).ready(function(){}); 使用jQuery的好處是它包裝了各種瀏覽器版本對DOM對象(javascript的DOM對象你應該知…

爬蟲數據executemany插入_金融數據的獲取——一個爬蟲的簡單例子

對量化投資策略進行研究&#xff0c;第一步就是獲取我們需要的數據。使用歷史數據能夠對策略進行回測&#xff0c;以驗證策略的有效性和可信性。另一方面&#xff0c;量化投資本身也是一種對數據的研究&#xff0c;因此它也必須遵循數據分析的相關步驟。作為一個業余的量化投資…

洛谷 P1736 創意吃魚法

P1736 創意吃魚法 題目描述 回到家中的貓貓把三桶魚全部轉移到了她那長方形大池子中&#xff0c;然后開始思考&#xff1a;到底要以何種方法吃魚呢&#xff08;貓貓就是這么可愛&#xff0c;吃魚也要想好吃法 ^_*&#xff09;。她發現&#xff0c;把大池子視為01矩陣&#xff0…

程序員面試中遇到問題

面試時候經常會問的一些問題(不斷補充中) 面試必備基礎題目(雖然不一定常用, 僅用于面試, 面試就是把人搞的都不會然后砍價, 當然您可以講我可以查資料完成, 但是面試的時候就是沒道理的, 起碼我是經常看到這些題). 如何把一段逗號分割的字符串轉換成一個數組? request.getAtt…

linux檢查swap配置,Linux環境下swap配置方法

8種機械鍵盤軸體對比本人程序員&#xff0c;要買一個寫代碼的鍵盤&#xff0c;請問紅軸和茶軸怎么選&#xff1f;前言安裝Linux系統之后&#xff0c;默認是沒有swap分區&#xff0c;那么我們怎樣增加和刪除swap分區。配置swap步驟1) 內存占用情況1free -hSwap: 0B 0B 0B2) 通過…