Hi,
I'm working on a TCP client program. (I've also done a little TCP server which seems to work fine to test it)
I've a "connect" function which establish a new connection like that :
^bool MyTCP : : connect(const std : : string host, const unsigned short hostPort)
{
try
{
if (mainGui) mainGui->setWxDiscutionText(wxString("Connection..."));
SocketAddress sa(host, hostPort);
MyTCPClient tcpClient(sa);
// run the tcpClient in a thread
Thread myThread;
myThread.start(tcpClient); // ---> cause an exception
return true;
}
catch (Exception& exc)
{
std : : cerr << exc.displayText() << std : : endl;
return false;
}
}^
Here is the MyTCPClient class :
^class MyTCPClient : public Runnable
{
public:
MyTCPClient(SocketAddress sa);
~MyTCPClient(void);
void run();
private:
StreamSocket sock;
};^
Today, the run() function doesn't do anything ( void MyTCPClient::run() { } ). It will display the text received from server, etc.
When executing the program, as soon as the "connect" function is called, i get an access violation exception when reading at 0x00000005.
If I don't call "myThread.start(tcpClient);" in the connect funtion, it works fine.
So, what am I doing wrong with thread ?





