I'm struggling with a problem for a while now trying to find out what am I doing wrong but I can figure it out. I'm a newbie to wxWidgets and multi-threading so please forgive me. I did read the pinned thread about Sockets but I couldn't get any closer to a solution. First of all:
IDE: Code::Blocks 17.12
OS: Debian 10 (on a virtual machine)
wxWidgets: 3.0.4.0
I have a class derived from wxThread:
Code: Select all
class myThread: public wxThread {
public:
myThread(myClass *src, myClass *dst);
virtual ~myThread();
protected:
virtual wxThread::ExitCode Entry();
private:
myClass *_src;
myClass *_dst;
wxSocketClient *_c;
};
Code: Select all
myThread::myThread(myClass *src, myClass *dst): wxThread(wxTHREAD_DETACHED) {
_src = src;
_dst = dst;
_c = nullptr;
}
myThread::~myThread() {
_dst = nullptr;
_src = nullptr;
_c = nullptr;
}
wxThread::ExitCode myThread::Entry() {
_c = new wxSocketClilent();
_c->SetTimeout(3); // if this will be greater than 3 app will crash
wxIPV4address ip;
ip.Hostname(_dst->GetIp());
ip.Service(_dst->GetPort());
if(_c->Connect(ip)) {
// do something
} else {
// failed to connect
}
_c->Destroy();
return (wxThread::ExitCode)0;
}
Code: Select all
myThread *t = new myThread(src, dst); // src and dst are NOT null pointers ;-)
if(t->Run() != wxTHREAD_NO_ERROR) {
// we have an error
}
Anyways, if I set the timeout for wxSocketClient to anything above 3 seconds than the app will crash after the specified time. When I setup a breakpoint on the _c->Connect(ip) line then I see this in the debug window as soon as this piece of code is ran:
Code: Select all
In __kernel_vsyscall () ()
../sysdeps/unix/sysv/linux/internal-signals.h: No such file or directory.
0xf6eb4382 in __libc_signal_restore_set (set=0xf51ac68c) at ../sysdeps/unix/sysv/linux/internal-signals.h:84
Code: Select all
Program terminated with signal SIGABRT, Aborted.
Thank you in advance for your help.