Solved

Winsock Overlapped I/O example

Posted on 2004-09-24
2
1,656 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now