`
iunknown
  • 浏览: 407966 次
社区版块
存档分类
最新评论

IOCP 摘要

阅读更多
windows 高级编程指南 第三版 Page 601

IIS 使用了一个相当复杂的算法来管理它的线程池。IIS 创建的最大线程数目是动态的。当IIS初始化时,对每个 CPU ,它最多允许创建 10 个线程。不过,根据客户请求,这一最大值可能会增加。IIS 设的最大值是计算机上的 RAM 的 M 字节数的两倍。

当一个客户请求要执行一个 ISAPI DLL 中的代码时,IIS 增大了池中的最大线程数目。当 ISAPI 函数返回时,IIS 减少了该值。这是因为 IIS 不知道 ISAPI DLL 函数要做什么事情。如果函数进入了一个无限循环,IIS 就失去了一个线程。所以 IIS 就增大了池中的最大线程数目。


Page 598
GetQueuedCompletionStatus返回可能有多种原因,如果传递无效完成端口句柄,函数返回False,GetLastError返回一个错误(ERROR_INVALID_HANDLE),如果超时,返回False, GetLastError返回WAIT_TIMEOUT, i/o完成队列删除一项,该表项是一个成功完成的I/O请求,则返回True。

当从 I/O 完成队列中删除一项时,有 lpdwNumberOfBytesTransferred, lpdwCompletionKey 和 lpOverlapped 参数指向的变量被设为反映该表项的信息。如果删除的表项代表一个成功完成的 I/O 请求,GQCS 返回 TRUE 。不过,如果删除的表项代表一个失败的 I/O 请求,GQCS 将返回 FALSE,调用 GetLastError 返回失败的原因。

可以通过检查 lpOverlapped 变量的值来判断 GQCS 失败的原因,如下面的代码所示:


DWORD dwNumberOfBytesTransferred, dwCompletionKey;

LPOVERLAPPED lpOverlapped;

BOOL fOk = GQCS( ..., &dwNumberOfBytesTransferred, &dwCompletionKey,
        &lpOverlapped, 1000 );

DWORD dwError = GetLastError();

if( fOk ) {
    // process a successfully completed I/O request.
} else {
    if( lpOverlapped != NULL ) {
        // process a failed completed I/O request.
        // dwError contains the reason for failure
    } else {
        if( dwError == WAIT_TIMEOUT ) {
            // Time-out while waiting for completed I/O entry
        } else {
            // Bad call to GQCS
            // dwError contains the reason for the bad call
        }
    }
}


http://itamarst.org/writings/win32sockets.html

引用

Differences in partial writes to TCP sockets (contributed by James Knight).
    In Unix, socket.send(buf) will buffer as much of buf as it has space for, and then return how much it accepted. This could be 0 or up to something around 128K. If you send some data and then some more, it will append to the previous buffer.

    In Windows, socket.send(buf) will either accept the entire buffer or raise ENOBUFS. Testing indicates that it will internally buffer any amount up to 50MB (this seems to be the total for either the process or the OS, I'm not sure). However, it will not incrementally accept more data to append to a socket's buffer until the big buffer has been completely emptied (seemingly down to the SO_SNDBUF length, which is 8192), but rather raises WSAEWOULDBLOCK instead.



<Network Programming for Microsoft Windows, Second Edition>

引用

Maximizing Connections
Maximizing the number of concurrent client connections is the more difficult of the two strategies. Handling the I/O on each connection becomes difficult. A server cannot simply post one or more sends or receives on each connection because the amount of memory (both in terms of locked pages and non-paged pool) is great. In this scenario, the server is interested in handling many connections at the expense of throughput on each connection. An example of this would be an instant messenger server. The server would handle many thousands of connections but would need to send or receive only a small number of bytes at a time.

For this strategy, the server does not necessarily want to post an overlapped receive on each connection because this would involve locking many pages for each of the receive buffers. Instead, the server can post an overlapped zero-byte receive. Once the receive completes, the server would perform a non-blocking receive until WSAEWOUDLBLOCK is returned. This allows the server to immediately receive all buffered data received on that connection. Because this model is geared toward clients that send data intermittently, it minimizes the number of locked pages but still allows processing of data on each connection.
分享到:
评论

相关推荐

    VC的IOCP开发,iocp类,demo

    在这个"VC的IOCP开发,iocp类,demo"中,我们将深入探讨IOCP的基本原理、如何在VC++环境中实现一个基于IOCP的服务器,并通过提供的"IOCPDemo"来理解其实现细节。 一、IOCP基础知识 IOCP是Windows系统内核提供的一个...

    学习iocp的例子学习iocp的例子

    **IO Completion Ports (IOCP) 是Windows操作系统中用于高并发网络编程的一种机制。它通过将I/O操作异步化,显著提高了系统处理大量并发连接的能力。以下是对IOCP的详细解释:** IOCP,全称Input/Output Completion...

    IOCP原理windows下实现

    在Windows操作系统中,I/O完成端口(Input/Output Completion Port,简称IOCP)是一种高效、多线程的I/O模型,特别适用于处理大量并发网络请求。本资源包旨在深入探讨IOCP的工作原理以及如何在Windows环境下实现一个...

    vc以IOCP完成端口方式实现网络数据传输 iocp服务器+客户端.zip

    在Windows系统中,I/O Completion Ports (IOCP) 是一种高效能的异步I/O模型,常用于网络编程,特别是高并发服务器的实现。本文将深入探讨如何利用Visual C++和IOCP完成端口技术来构建一个网络数据传输的服务器和...

    IOCP文件客户端 IOCP文件客户端

    IOCP(Input/Output Completion Port,输入/输出完成端口)是Windows操作系统提供的一种高度优化的I/O模型,尤其适用于高并发的网络编程场景。它允许应用程序通过一个或多个线程处理大量的I/O请求,提高了系统资源的...

    高效率IOCP的UDP通信服务端

    本文将深入探讨如何构建一个高效率的UDP通信服务端,利用IOCP(I/O完成端口)技术来提升性能。IOCP是Windows操作系统提供的一种高级I/O模型,它可以有效地处理大量并发的I/O操作,特别适合于高负载、高性能的网络...

    IOCP.NET(强大的IOCP托管库)

    **IOCP.NET:深入理解与应用** IOCP.NET是一个针对C#.NET和VB.NET开发的高性能、高效率的异步I/O复用库,它基于Windows操作系统的完成端口(IO Completion Port,简称IOCP)机制。IOCP是Windows内核提供的一种优化...

    IOCP 服务器端 IOCP 服务器端

    IOCP(I/O Completion Port,I/O 完成端口)是 Windows 操作系统提供的一种高效、可扩展的异步I/O模型,尤其适用于高并发的网络服务器开发。本文将详细探讨IOCP的工作原理、使用场景以及如何在服务器端实现。 ### ...

    完整的IOCP实例

    IOCP(Input/Output Completion Port,输入/输出完成端口)是Windows操作系统提供的一种高度优化的多线程I/O模型,常用于构建高性能的游戏服务器、网络应用等。在这个"完整的IOCP实例"中,开发者使用了NT6线程池和...

    c++版IOCP完成端口源码

    2. **绑定套接字到IOCP**:使用`CreateIoCompletionPort`函数将TCP或UDP套接字与IOCP关联,这样所有针对这些套接字的I/O操作完成后都会将通知发送到IOCP。 3. **接收客户端连接**:对于TCP,服务器会监听特定端口,...

    IOCP服务器模块.rar

    《深入解析IOCP服务器模块——基于易语言的实现》 IOCP(I/O完成端口,Input/Output Completion Port)是Windows操作系统提供的一种高效的异步I/O模型,它被广泛应用于高并发、高性能的网络服务器中。IOCP服务器...

    iocp服务器的源码

    【标题】:“IOCp服务器的源码” 在Windows操作系统中,I/O完成端口(I/O Completion Port,简称IOCP)是一种高效的多线程异步I/O模型,它被广泛应用于高并发网络服务,如游戏服务器、数据库服务器等。本项目提供了...

    iocp资料技术文档

    **IOCP(I/O Completion Port)技术文档** IOCP,全称I/O完成端口,是Windows操作系统中的一种高效I/O模型,尤其适用于处理大量并发I/O操作的系统。它是Windows系统内核提供的一个同步机制,允许应用程序通过单一的...

    IOCP类 改写的

    标题中的"IOCP类 改写"指的是对基于I/O完成端口(Input/Output Completion Port,简称IOCP)的类进行了重构或优化。IOCP是Windows操作系统提供的一种高效率的异步I/O模型,特别适合用于高性能的TCP服务器开发。这种...

    windows IOCP示例代码

    在Windows操作系统中,I/O完成端口(Input/Output Completion Ports,简称IOCP)是一种高效、可扩展的I/O模型,特别适用于处理大量的并发连接。IOCP结合了系统线程池,可以有效地管理多线程环境下的I/O操作,从而在...

    IOCP客户端模拟程序

    《IOCP客户端模拟程序详解与应用》 IOCP(I/O完成端口)是Windows操作系统中的一种高效异步I/O模型,它在处理大量并发I/O请求时表现出极高的性能和可扩展性。本篇文章将深入探讨IOCP客户端模拟程序的设计、实现以及...

    IOCP.rar_IOCP_delphi iocp_iocp csdn_iocp delphi

    标题中的“IOCP.rar”指的是一个关于IOCP(Input/Output Completion Port,输入/输出完成端口)技术的压缩文件,主要针对使用Delphi编程语言的开发者。IOCP是Windows操作系统提供的一种高度优化的异步I/O模型,常...

    IOCP经典讲解

    在计算机编程领域,尤其是网络通信和服务器开发中,完成端口(IOCP,I/O Completion Port)是一种高效处理异步I/O操作的技术。本资源针对IOCP进行了详细的讲解,旨在帮助开发者理解并掌握这一关键概念,以提升服务器...

    IOCP完成端口原理

    IOCP(Input/Output Completion Port,输入/输出完成端口)是Windows操作系统提供的一种高效、高性能的异步I/O模型,特别适用于构建高并发的服务器应用程序。本文将深入探讨IOCP的基本原理、特点以及相关技术概念。 ...

Global site tag (gtag.js) - Google Analytics