iocp

Libevent源码分析-----配置event_base

▼魔方 西西 提交于 2019-12-07 03:17:24
前面的博文都是讲一些Libevent的一些辅助结构,现在来讲一下关键结构体:event_base。 这里作一个提醒,在阅读Libevent源码时,会经常看到backend这个单词。其直译是“后端”。实际上其指的是Libevent内部使用的多路IO复用函数,多路IO复用函数就是select、poll、epoll这类函数。本系列博文中,为了叙述方便,“多路IO复用函数”与“后端”这两种说法都会采用。 配置结构体: 通常我们获取event_base都是通过event_base_new()这个无参函数。使用这个无参函数,只能得到一个默认配置的event_base结构体。本文主要是讲一些怎么获取一个非默认配置的event_base以及可以对event_base进行哪些配置。 还是先看一下event_base_new函数吧。 //event.c文件 struct event_base * event_base_new(void) { struct event_base *base = NULL; struct event_config *cfg = event_config_new(); if (cfg) { base = event_base_new_with_config(cfg); event_config_free(cfg); } return base; } 可以看到

让Libevent 在window下 支持 IOCP

一笑奈何 提交于 2019-12-06 12:54:14
Libevent 的强大就不说了,但由于在window下使用的是 select 机制 ,除了效率低下意外还有一个讨厌的"FD_SETSIZE"限制,所以一直 希望能支持IOCP,可是现在已经到2.0还是没能够支持。 无意中在网上发现了个支持IOCP的libevent版本,是1.4.7版的。不过没关系,把其中的一个关键文件"win32iocp.c"拷贝到最新的1.4.14b版本中,并在"event.c" 中修改: ..... #ifdef HAVE_POLL extern const struct eventop pollops; #endif #ifdef HAVE_EPOLL extern const struct eventop epollops; #endif #ifdef HAVE_WORKING_KQUEUE extern const struct eventop kqops; #endif #ifdef HAVE_DEVPOLL extern const struct eventop devpollops; #endif #ifdef WIN32 #ifndef _EVENT_NOIOCP extern const struct eventop win32iocpops; #endif extern const struct eventop win32ops;

How do Completion Port Threads of the Thread Pool behave during async I/O in .NET / .NET Core?

可紊 提交于 2019-12-06 09:38:34
The .NET / .NET Core Thread Pool uses two different categories of threads internally: worker threads and I/O Completion Port (IOCP) threads. Both are just usual managed threads, but used for different purposes. Via different APIs (e.g. Task.Start or ThreadPool.QueueUserWorkItem ) I can start CPU-bound async operations on the worker threads (which shouldn't block, otherwise the Thread Pool would probably create additional worker threads). But what about performing I/O-bound asynchronous operations? How do the IOCP threads behave exactly in these situations? Specifically, I have the following

TCP/IP server using IOCP. Occasional data corruption in receive buffers

南楼画角 提交于 2019-12-06 08:27:33
问题 I’ve been working on an TCP/IP IOCP server application. I’ve been testing performance (which seems in line with TCP throughput testing utilities) and now have been testing data integrity – this is where I am getting some “weirdness”. As an initial test, I decided to have a test client send a 1MB block of data over and over where that block is just a sequence of integers incremented one after the other. The idea being that I can verify that each received buffer of data is consistent with no

Mono and C# IOCP: Is it a good idea?

牧云@^-^@ 提交于 2019-12-06 07:43:31
问题 I'm porting a c++ app to c# that uses IOCP on it's server. Can mono handle IOCP as well as windows? will i get comparable performance to c++ or i should try something else? thanks 回答1: The main overhead in IOCP is the IO not the language. You should expect the same performance from the C# code as in C++ (Given the mature state that Mono is in). 回答2: Do you target mono for windows? If it is linux then there is a different async i/o model, not completion ports. I assume mono developers did

Delphi TClientSocket replacement using winsock2 and IOCP?

。_饼干妹妹 提交于 2019-12-06 06:58:06
Is there such a thing? It needs to be asynchronous (no Indy). Try HPScktSrvr - http://www.torry.net/pages.php?id=220#939383 These may or may not be what you are looking for, but worth a shot: Ararat Synapse - For Delphi 2009 support you need to get the latest from SVN. /n Software's IP*Works - Commercial, but very full featured. Good luck! Check http://voipobjects.com/index.php?page=delphi-iocp-library It is migrated iocpclasses.sourceforge.net (i'm an author). Enjoy :) 来源: https://stackoverflow.com/questions/1072510/delphi-tclientsocket-replacement-using-winsock2-and-iocp

TCP/IP IOCP received data sometimes corrupt - Visual C++ on Windows

给你一囗甜甜゛ 提交于 2019-12-06 00:35:13
问题 I am writing a simple test ICOP client and server to ensure I am using the API correctly and that the data the client sending is being received correctly by the server. I have included all the code for this question. This is where I ran into some problems, that the data within the receive buffers sometimes seems to be corrupted (corrupted in that sometimes chunks of data within buffers can be out of order or missing). To be clear, this is data within individual receive buffers, I don’t mean

some OVERLAPS using WSASend not returning in a timely manner using GetQueuedCompletionStatus?

人盡茶涼 提交于 2019-12-05 10:13:14
问题 Background: I'm using CreateIoCompletionPort, WSASend/Recv, and GetQueuedCompletionStatus to do overlapped socket io on my server. For flow control, when sending to the client, I only allow several WSASend() to be called when all pending OVERLAPs have popped off the IOCP. Problem: Recently, there are occassions when the OVERLAPs do not get returned to the IOCP. The thread calling GetQueuedCompletionStatus does not get them and they remain in my local pending queue. I've verified that the

I/O Completion Port, How to free Per Socket Context and Per I/O Context?

安稳与你 提交于 2019-12-04 21:11:37
I'm using IOCP on UDP socket, and the UDP socket may be closed in another thread. So, how can I free Per Socket Context and Per I/O Context which associated with SOCKET safely? When I close the socket, there will still be un-completed I/O request in kernel queue. If I free context just when socket closed, the GetQueueCompletionStatus may failed. Now, my question is when to free context? Len Holgate I use reference counting on all of my per socket and per I/O data structures. It makes this kind of thing easy as they are deleted when their references drop to 0. For some example code which shows

IOCP AcceptEx not creating completion upon connect

馋奶兔 提交于 2019-12-04 15:53:26
问题 I am currently trying some new libraries (IOCP) for socket programming. And I've stumbled upon the AcceptEx functionality to enable async connections. As the documentation says: The AcceptEx function uses overlapped I/O, unlike the accept function. If your application uses AcceptEx, it can service a large number of clients with a relatively small number of threads. As with all overlapped Windows functions, either Windows events or completion ports can be used as a completion notification