Solved

AsyncSelect and windows callback on WinXP

Posted on 2004-09-16
4
389 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
[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
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

615 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