Solved

AsyncSelect and windows callback on WinXP

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

730 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