Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Winsock Overlapped I/O example

Posted on 2004-09-24
2
Medium Priority
?
1,810 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 1200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
  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 …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

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