Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

AsyncSelect and windows callback on WinXP

Posted on 2004-09-16
4
Medium Priority
?
412 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 1500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
  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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

916 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