Sockets - 2.8 to 3.0.4

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
In need of some credit
In need of some credit
Posts: 1
Joined: Thu May 10, 2018 1:55 pm

Sockets - 2.8 to 3.0.4

Postby AKP » Thu May 10, 2018 2:34 pm

I have migrated from wxWidgets 2.8 to 3.0.4. After succesfull compilation i see that the client is not able to send any data to server. However when client calls connect(), connect returns success. But when client sends data to server, server is not receiving it. However the server had not got the connection callback also. Following is the code snippet which will help to understand the situation better:
Sockets is unix socket.

Server code:

Code: Select all

    wxIPV4address stAddr;
    MySSocket = new wxSocketServer(stAddr);

    MySSocket->SetEventHandler(*this, MY_SOCKET_CONNECT_ID); // Registering callback function
    MySSocket->SetNotify(wxSOCKET_CONNECTION_FLAG) ;

Event table in socket code:

Code: Select all

BEGIN_EVENT_TABLE(MyServer, wxEvtHandler)
    EVT_SOCKET(MY_SOCKET_CONNECT_ID, MyServer::onConnectEvent) //Callback function for connection
    EVT_SOCKET(MY_SOCKET_ID, MyServer::onSocketEvent)                      //Callback function for socket events - like read

Client Code:

Code: Select all

wxIPV4address stAddr;

MyCSocket = new wxSocketClient();
                MyCSocket->Connect(stAddr, true);

Above while loop exits, after which MyCSocket->write() function is called to send data to server. After Write() the client expects data from server which never comes. So the execution hangs at MyCSocket->Read().

However the above code works perfectly well with wxWidgets 2.8, and fails to work (hangs at Read()) on wxWidgets 3.0.4.

Please let me know if I have to enable any flags or change any piece of code in the above flow, or please share any working socket examples for wxWidgets3.0.4.
Kindly let me know if you need more info.
Last edited by doublemax on Thu May 10, 2018 3:36 pm, edited 1 time in total.
Reason: Added code tags

User avatar
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France

Re: Sockets - 2.8 to 3.0.4

Postby eranon » Thu May 10, 2018 7:40 pm

Hello, Never used wxSocketClient/Server myself, but found this old thread talking about issue migrating from 2.8 to 3.0:!topic ... Geq1404ERk
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]

Return to “C++ Development”

Who is online

Users browsing this forum: Google [Bot], Wanderer82 and 24 guests