wxSocketClient is killing me!
Posted: Wed Jun 22, 2005 5:37 pm
Ok, I'm trying to open a socket connection and it's segfaulting. I have no idea why, there's no real indicators in the backtrace, I'm at a total loss. I think I have everything implemented that's necessary.
Below, wxString host is passed from a modal dialog with a wxTextCtrl as:
if (UI->DoConnect(text_address->GetValue())) {
The wxMessageBox does indeed show the right address, yay.
connection->Connect is the call that dies with a segfault. gdb doesn't drill into the Connect call, so it's got to be that connection doesn't exist (or something like that)
This is the UI ctor section pertaining to the connection:
OnSocketEvent is a stub that does nothing with the events.
So why is connection->Connect() dying ??!?
Below, wxString host is passed from a modal dialog with a wxTextCtrl as:
if (UI->DoConnect(text_address->GetValue())) {
The wxMessageBox does indeed show the right address, yay.
connection->Connect is the call that dies with a segfault. gdb doesn't drill into the Connect call, so it's got to be that connection doesn't exist (or something like that)
Code: Select all
bool UI::DoConnect(wxString host)
{
wxIPV4address addr;
addr.Hostname(host);
addr.Service(4242);
//(void)wxMessageBox((addr.Hostname()).c_str(), _T("test"), wxICON_INFORMATION);
connection->Connect(addr, false);
connection->WaitOnConnect(10);
if (connection->IsConnected())
return true;
else
return false;
}
Code: Select all
// Create the socket
connection = new wxSocketClient();
// Setup the event handler and subscribe to most events
connection->SetEventHandler(*this, Socket_ID);
connection->SetNotify(wxSOCKET_CONNECTION_FLAG |
wxSOCKET_INPUT_FLAG |
wxSOCKET_LOST_FLAG);
connection->Notify(true);
So why is connection->Connect() dying ??!?