Solved

Winsock Overlapped I/O example

Posted on 2004-09-24
2
1,713 Views
Last Modified: 2012-06-27
Hi,

I've got a threaded server that accepts about 500 connections.  From what I've read the best winsock method is to use Overlapped I/O.  can anyone point me to an example that I could look at or give me some pointers on Overlapped I/O in winsock.  I'm not using the winsock2 lib and no MFC.  This is the basic method I'm using right now but I'm getting data loss.

1. Accept connection & create a thread
2. Recv in the thread until the term signal is sent
3. Based on recv buffer send data back
4. Clean up and close thread when term signal is sent
0
Comment
Question by:windows_programing
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 300 total points
ID: 12144952
Check out http://win32.mvps.org/network/sockhim.html and the sample code at http://win32.mvps.org/network/sockhim.zip

If I may say so myself, the small demonstration project below is superior in both readability and practical applicability. It demonstrates a small server that:
-      uses sockets in overlapped mode, attached to an I/O completion port (IOCP);
-      uses AcceptEx() to route new connections through the IOCP;
-      uses GetQueuedCompletionPacket() to retrieve the results of asynchronous (overlapped) I/O requests;
-      uses PostQueuedCompletionStatus() to send special notifications to the worker threads servicing the IOCP;
-      uses TransmitFile() like an FTP server might;
-      and demonstrates a simple state machine implementing an interactive server, which accepts commands and returns meaningful results. Simple echo servers, bah.
0
 

Author Comment

by:windows_programing
ID: 12212990
Thanks JKR!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
White board coding practice 3 92
Issues with C++ Class 19 101
How to Correctly derive class from CWinThread in MFC 4 69
Coding for the first time 9 37
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question