Solved

Winsock Overlapped I/O example

Posted on 2004-09-24
2
1,736 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

739 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