Re: Losing UDP packets with MFC Sockets



Vicent Soler wrote:
Hi AliR,

I think that this kind of implementation have a problem in my code:

1.- I'm using OLE Automation with two applications: the engine is written in VC++ and the GUI in VB.

2.- The UDP socket is not always open and depend on the working mode of the GUI. It means that the UDP socket can be open or closed many times during the application's life.

3.- To open/close the UDP socket the GUI calls a method from the Engine to proceed and then the engine processes the call and opens/closes the UDP socket. So, as you can imagine, I need a unique thread to manage UDP sockets because the GUI is waiting for the response. While the Engine is processing the call, the GUI is block waiting for the response and if after that the response is valid, the GUI continues with the operations.

4.- And another problem, how can I kill the thread from the main application once it is running.

Mmmmm.... Maybe I'm wrong but I don't see the solution you are defending. I'll try to investigate more...

Vicent

The thread is a CWinThread-derived object. It has a message map and you can post messages to it (PostThreadMessage and ON_THREAD_MESSAGE). When you want to kill the thread you post a user-defined message to it asking it to exit. The message handler in the thread is called, via the message map. It shuts down the thread by calling PostQuitMessage(0).


--
Scott McPhillips [VC++ MVP]

.



Relevant Pages

  • Re: Losing UDP packets with MFC Sockets
    ... VC++ and the GUI in VB. ... It means that the UDP socket can be open or closed many times during the ... 3.- To open/close the UDP socket the GUI calls a method from the Engine to ...
    (microsoft.public.vc.mfc)
  • GUI framework for game/engine tools?
    ... supplementing a game engine. ... I've read many optimistic things about the near future of MFC as a GUI ... for example with .NET framework, but this is not tested, only an ...
    (comp.games.development.programming.misc)
  • Re: Losing UDP packets with MFC Sockets
    ... I'm implementig a CWinThread-derived class which contains my MFC CAsyncSoket ... one for managing the UDP socket. ... ..- The problem is that users introduce the Port Number from the GUI and then ... accessing the Socket's thread directly and calling the Open method. ...
    (microsoft.public.vc.mfc)
  • Re: Newbie Needs Ada Advice
    ... this document to the "engine", which actually controls the microscope. ... accomplish that in practically any GUI library in two days. ... You can call Ada from Matlab, same as you would call C. ...
    (comp.lang.ada)
  • Re: Its not a bug its ChessBase
    ... For all of you who like to thow money in the throat of reliable chess GUI ... You should load the engine Fruit. ... infinite analysis in a forced mate in N exceeds 2N by any significant ... I suspect certain variants of selective extentions get into ...
    (rec.games.chess.computer)