Solved

AsyncSelect and windows callback on WinXP

Posted on 2004-09-16
4
376 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

  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 …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

746 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

12 Experts available now in Live!

Get 1:1 Help Now