Discussion:
wxAppConsole and wxTCPServer
Carsten A. Arnholm
2014-06-22 22:50:34 UTC
Permalink
Hi,

I am using wx3.0. I need to create a console application to run on
Raspberry PI receiving TCP/IP messages and I want to use derivatives of
wxTCPServer and wxTCPConnection (at least that is what I am trying).

I am testing under Ubuntu, and I am able to get client/server
connections working fine when both client and server apps are GUI
applications.

But I need the server application to run on Raspberry PI and it should
be a console application. So I have tried to use wxAppConsole as follows
(ioServer is derived from wxTCPServer):

class MyApp: public wxAppConsole
{
public:
virtual bool OnInit();
virtual int OnRun();
private:
ioServer m_server;
};

wxIMPLEMENT_APP_CONSOLE(MyApp);

bool MyApp::OnInit()
{
wxString port = "1234";
m_server.Create(port);
return true;
}

int MyApp::OnRun()
{
cout<<"OnRun"<<endl;

// create event loop
wxEventLoop loop;
// order wxAppConsole to process events
ProcessPendingEvents();

// start created event loop
return loop.Run();
}

Somehow, this does not work, i.e. I am not receiving any connection
requests. What am I missing?

Best regards
Carsten Arnholm
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-06-23 00:32:51 UTC
Permalink
On Mon, 23 Jun 2014 00:50:34 +0200 Carsten A. Arnholm wrote:

CAA> But I need the server application to run on Raspberry PI and it should
CAA> be a console application. So I have tried to use wxAppConsole as follows

Have you looked at samples/sockets/baseserver.cpp? It's a bit complicated
but you should be able to extract just the minimal working part, whether
you use threads or not.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Carsten A. Arnholm
2014-06-23 05:21:26 UTC
Permalink
Post by Vadim Zeitlin
CAA> But I need the server application to run on Raspberry PI and it should
CAA> be a console application. So I have tried to use wxAppConsole as follows
Have you looked at samples/sockets/baseserver.cpp? It's a bit complicated
but you should be able to extract just the minimal working part, whether
you use threads or not.
Ok, thanks for the pointer. I will look at that now.

Best regards
Carsten Arnholm
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...