iocp

所属分类:网络编程
开发工具:Visual C++
文件大小:42KB
下载次数:109
上传日期:2008-07-16 11:20:04
上 传 者kongjun1981108
说明:  应用完成端口进行tcp的连接,数据的发送,接收。
(Completed application tcp port connection, data to send, receive.)

文件列表:
iocp\iocp.ncb (44032, 2007-11-01)
iocp\iocp.sln (1542, 2007-11-01)
iocp\iocp.suo (12800, 2007-11-01)
iocp\iocp.vcproj (2021, 2007-11-01)
iocp\iocp.vcproj.old (1771, 2006-03-03)
iocp\IocpClient.Cpp (14571, 2006-03-03)
iocp\iocpclient.ncb (27648, 2007-11-01)
iocp\iocpclient.vcproj (1900, 2007-11-01)
iocp\iocpclient.vcproj.old (1707, 2006-03-03)
iocp\IocpServer.Cpp (28025, 2006-03-03)
iocp\IocpServer.h (2832, 2006-03-03)
iocp\iocpserver.ncb (35840, 2007-11-01)
iocp\iocpserver.vcproj (1956, 2007-11-01)
iocp\iocpserver.vcproj.old (1763, 2006-03-03)
iocp\IocpServerex.Cpp (32808, 2006-03-03)
iocp\Makefile (833, 2006-03-03)
iocp (0, 2007-11-01)

readme.txt THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. Copyright (C) 19*** Microsoft Corporation. All Rights Reserved. About: This directory contains 3 programs, an I/O Completion Port (IOCP) Winsock server using WSAAccept (iocpserver), an IOCP Winsock server using AcceptEx (iocpserverex) and a simple multithreaded Winsock client (iocpclient) used to test either server. Unless otherwise noted, comments about iocpserver apply to iocpserverex as well. Iocpserver is a simple echo program that uses IOCP to receive data from and echo data back to a sending client. The server program supports multiple clients connecting via TCP/IP and sending arbitrary sized data buffers which the server then echoes back to the client. For convenience a very simple client program, iocpclient, was developed to connect and continually send data to the server to stress it using multiple threads (NOTE: please see the comments in iocpclient.cpp about scaleability of multithreaded applications). Direct IOCP support was added to Winsock 2 and is fully implemented on the NT platform. IOCP support is not available on Win9x platforms. IOCPs in Winsock2 are modeled on the Win32 IOCP model and compatible with them. IOCPs provide a model for developing very high performance and very scablable server programs. As a consequence, iocpserver can only run on NT. Use of IOCP-capable functions in Winsock 2 (such as WSASend and WSARecv) is preferred over using IOCPs in WriteFile and ReadFile when using sockets. Additionally, the client is designed to run only on NT as well. The basic idea is that this server continuously accepts connection requests from a client program. When this happens, the accepted socket descriptor is added to the existing IOCP and an inital receive (WSARecv) is posted on that socket. When the client then sends data on that socket, an I/O packet will be delivered and handled by one of the server's worker threads. The worker thread echoes the data back to the sender by posting a send (WSASend) containing all the data just received. When sending the data back to the client completes, another I/O packet will be delivered and again handled by one of the server's worker threads. Assuming all the data that needed to be sent was actually sent, another receive (WSARecv) is once again posted and the scenario repeats itself until the client stops sending data. The client and server can be shut down by pressing CTRL-C. The server can restart without exiting the process by pressing CTL-BRK. The basic difference between iocpserver and iocpserverex is that AcceptEx (used in iocpserverex) allows data to be returned from an accepted connection and AcceptEx can be executed in an overlapped manner and thus be used in conjunction with an IOCP. Build: Run nmake to use the supplied makefile or create a VC project for iocpserver, iocpserverex, and iocpclient. When creating a project in VC remember to link with the Winsock 2 library ws2_32.lib. Also, use the headers and libs from the April*** Platform SDK or later. Usage: Start the server and wait for connections on port 6001 iocpserver -e:6001 Start the client with 32 threads in verbose mode and connect to port 6001 on the server machine, server_machine. iocpclient -n:server_machine -t:32 -v -e:6001

近期下载者

相关文件


收藏者