Application Server in a Console
Liam Whalen
lwhalen at cabletv.on.ca
Fri Oct 5 11:29:13 PDT 2007
> ----- Original Message -----
> From: Mauro Cordon
> To: wx-users at lists.wxwidgets.org
> Sent: Friday, October 05, 2007 10:35 AM
> Subject: Application Server in a Console
> I want to create a server of applications, but it must work in a
> console, but answers the events to the wxSocketBase.
> What can I do ? Use wxApp ? What send to SetEventHandler() ?
> I use wxGTK and wxMSW.
> From: "Liam Whalen" <lwhalen at cabletv.on.ca>
>I'm not sure if there are console specific ways to do this but you can do
>it using wxApp. As far as I can tell you will still need a wxWindow object
>to get the event handling properties started. However >you do not need to
>Show() this window, it mearly needs to exist.
Ok ignore my last post. After looking at my own code I have a much simpler
method that does not involve a wxWindow.
In your class that has wxSocketBase inherit from wxEvtHandler.
In your class constructor do the following
this->theSocket->SetEventHandler(*this, SERVER_ID);
//set the event handler
this->Connect( wxEVT_SOCKET,
wxSocketEventHandler(YourClassWithwxSocketBaseReference::OnServerEvent),
NULL, this);
This will set up the server to listen for incoming connections.
In your OnServerEvent function you want to create a new socket base and then
use this code
theSocketBase->SerEventHandler(*this, SOCKET_ID);
this->Connect( wxEVT_SOCKET,
wxSocketEventHandler(YourClassWithwxSocketBaseReference::OnSocketEvent ),
NULL, this );
I think this, as a whole, makes much more sense than using wxWindows. It
seems you have helped me as well with your question.
Liam
More information about the wx-users
mailing list