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
Solved

AsyncSelect and windows callback on WinXP

Posted on 2004-09-16
4
383 Views
Last Modified: 2011-10-03
Hi,

  I was wondering how you make a simple server with a callback fonction? Am trying to do so and when I receive
the first callback message it get there at one point and then receive another message and start again even before
the program release itself and wait for another message to be dispatch to it. I'm using asyncselect on my socket stream
and this server accept the first connection but again as I said it is not finish another callback(message) get dispatch to
the window and right at the first procedure that get out of the main callback procedure it freeze there and cannot get beyong that . I am doing test localy for the moment so there is not a ton that try to connect at my server.

I'm running on WinXP and compile with the package of Dev-C++(GCC)

Thank you
0
Comment
Question by:Dogofwars
  • 3
4 Comments
 
LVL 8

Accepted Solution

by:
mxjijo earned 500 total points
ID: 12088057

The solution is to compleate processing as fast as possible and return from the windows message loop so that
you can receive the next messge(s). If you think the data processing would take longer, then you need to copy
the data into a queue of your own and let a worker thread do the data processing. This way your OnReceive() routine
can return immediately. In any case, you should NOT spend too long inside OnReceive() function.

This is the problem if you user MFC sockets, which are driven by windows messaging.
If possible use plain Win32 sockets. Use WSAEventSelect() instead of AsyncSelect()

0
 

Author Comment

by:Dogofwars
ID: 12092752
I have found my problem to be one that get stick into a infinit loop, got a variable mistaken for another though
It's still strange the Messagebox windows were not displayed in order?? I'll accept you answer like that but tell
me what is the difference between WSAEventSelect and AsyncSelect beside that one is based on event and the
other one the message pump that also require a window or dialog box?

0
 

Author Comment

by:Dogofwars
ID: 12092866
I use palin Win32 sockets by the way ;)
0
 

Author Comment

by:Dogofwars
ID: 12092867
I use plain Win32 sockets by the way ;) -> Sorry for the typo ;)
I made myself a wrapper(class) though
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

  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 …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

839 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