Solved

Winsock Overlapped I/O example

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  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 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…
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.

630 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