io-completion-ports

SocketAsyncEventArgs buffer is full of zeroes

半腔热情 提交于 2020-01-22 20:09:16
问题 I'm writing a message layer for my distributed system. I'm using IOCP, ie the Socket.XXXAsync methods. Here's something pretty close to what I'm doing (in fact, my receive function is based on his): http://vadmyst.blogspot.com/2008/05/sample-code-for-tcp-server-using.html What I've found now is that at the start of the program (two test servers talking to each other) I each time get a number of SAEA objects where the .Buffer is entirely filled with zeroes, yet the .BytesTransferred is the

GetQueuedCompletionStatus blocks forever

孤街浪徒 提交于 2019-12-12 20:28:01
问题 I'm writing a server application and I want to use IOCompletion ports, so I wrote a prototype for the server, but I'm facing a problem with GetQueuedCompletionStatus that it never returns(it blocks). Below is my code: bool CreateSocketOverlappedServer() { WSADATA wsaData; SOCKADDR_IN sockaddr; if(WSAStartup(MAKEWORD(2,2,),&wsaData)){ _tprintf(_T("Unable to start up\n")); return false; } SrvSocket = WSASocket(AF_INET,SOCK_STREAM,0,NULL,NULL,WSA_FLAG_OVERLAPPED); if(SrvSocket==INVALID_SOCKET){

getting AccessViolationException in IOCompletionCallback

蹲街弑〆低调 提交于 2019-12-11 08:45:59
问题 I get the following exception on application startup: System.AccessViolationException at System.Threading.Overlapped.get_iocbHelper() at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP) That's the entire call stack. It only happens one in twenty runs right on application startup. I do use IOCompletion in my socket code. I assume it is related to that. However, why would this exception not show when I call Socket

Sockets using GetQueuedCompletionStatus and ERROR_MORE_DATA

半城伤御伤魂 提交于 2019-12-10 18:03:19
问题 I am trying to use GetQueuedCompletionStatus with winsocks, but I can't seem to get it right. The procedure is as follows: void foo() { ... SOCKET sck = WSASocket(AF_INET, SOCK_DGRAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED); .... bind(sck,(struct sockaddr *)&addr,sizeof(struct sockaddr_in)); HANDLE hPort = CreateIoCompletionPort((HANDLE)sck, NULL, 0, 0 ); OVERLAPPED pOverlapped = {0,}; WSARecvFrom(sck,NULL,0,NULL,NULL,(struct sockaddr *)&laddr,&lsize,&pOverlapped,0); BOOL bReturn =

Resources To learn IOCP On Windows

点点圈 提交于 2019-12-04 14:34:52
问题 I recently was made aware of this thing called IOCP on windows and i began searching for more information on it but i couldn't find anything up to date (most of the examples were on codeproject almost 5 years old) and not too many guides or tutorials. Can anyone recommend any up to date resources about it in the form of online tutorials or example projects (that you wrote and can share or other open source projects) or even a book about it because if it's as good as it sounds i plan to use it

Resources To learn IOCP On Windows

自作多情 提交于 2019-12-03 08:29:25
I recently was made aware of this thing called IOCP on windows and i began searching for more information on it but i couldn't find anything up to date (most of the examples were on codeproject almost 5 years old) and not too many guides or tutorials. Can anyone recommend any up to date resources about it in the form of online tutorials or example projects (that you wrote and can share or other open source projects) or even a book about it because if it's as good as it sounds i plan to use it extensively so i will invest in it. Thank You. IOCP is a feature that has been in Windows since the

HttpWebRequest and I/O completion ports

那年仲夏 提交于 2019-11-30 15:48:45
问题 I'm working on an application that requires for one type of message to go hit a database, and the other type of message to go and hit some external xml api. I have to process A LOT... one of the big challenges is to get HttpWebRequest class performing well. I initially started with just using the standard synchronous methods and threadpooling the whole thing. This was not good. So after a bit of reading I saw that the recommended way to do this was to use the Begin/End methods to delegate the

C# async/await chaining with ConfigureAwait(false)

青春壹個敷衍的年華 提交于 2019-11-29 09:59:46
Based on numerous books and blogs including this excellent one here , it is clear that when one writes a dll library exposing helper async methods i.e. the wrapper methods, it is generally considered a best practice to internally complete the I/O task of actual async methods on a threadpool thread like so (pseudo code shown below for brevity and I'm using HttpClient as an example) public Async Task<HttpResponseMessage> MyMethodAsync(..) { ... var httpClient = new HttpClient(..); var response = await httpClient.PostAsJsonAsync(..).ConfigureAwait(false); ... return response; } The key here is

C# async/await chaining with ConfigureAwait(false)

偶尔善良 提交于 2019-11-28 03:14:16
问题 Based on numerous books and blogs including this excellent one here, it is clear that when one writes a dll library exposing helper async methods i.e. the wrapper methods, it is generally considered a best practice to internally complete the I/O task of actual async methods on a threadpool thread like so (pseudo code shown below for brevity and I'm using HttpClient as an example) public Async Task<HttpResponseMessage> MyMethodAsync(..) { ... var httpClient = new HttpClient(..); var response =

Win32 Overlapped I/O - Completion routines or WaitForMultipleObjects?

纵然是瞬间 提交于 2019-11-27 17:38:17
I'm wondering which approach is faster and why ? While writing a Win32 server I have read a lot about the Completion Ports and the Overlapped I/O, but I have not read anything to suggest which set of API's yields the best results in the server. Should I use completion routines, or should I use the WaitForMultipleObjects API and why ? You suggest two methods of doing overlapped I/O and ignore the third (or I'm misunderstanding your question). When you issue an overlapped operation, a WSARecv() for example, you can specify an OVERLAPPED structure which contains an event and you can wait for that