Does anybody know when wxSocket_LOST event be generated?
I used this code:
M_socket->Connect(server,false);
M_socket->WaitOnConnect(100,10);
Then I always get the lost event while the socket is really open, I can read and write information to that socket. By the way, I used a other thread to create and open this socket, not in the main thread.
Thanks!
Bo
wxSocket Event problem
-
- Knows some wx things
- Posts: 38
- Joined: Thu Jun 09, 2005 1:44 am
- Location: china
-
- Knows some wx things
- Posts: 38
- Joined: Thu Jun 09, 2005 1:44 am
- Location: china
-
- Super wx Problem Solver
- Posts: 424
- Joined: Tue Jul 12, 2005 8:44 pm
- Location: Alabama, USA
You can specify the events you want to receive by using wxSocketBase::Notify().
http://www.wxwidgets.org/manuals/2.6.2/ ... esetnotify
From the documentation
will return true if successful and false if not successful, but no events will be received. Instead of using this or WaitOnConnect(), simply use
and handle the wxSOCKET_CONNECTION and wxSOCKET_LOST events. Also, use IsConnected() in the wxSOCKET_CONNECTION event to insure that the client is truly connected.
-Scott
http://www.wxwidgets.org/manuals/2.6.2/ ... esetnotify
From the documentation
So, usingwxSocketClient::Connect
bool Connect(wxSockAddress& address, bool wait = true)
Connects to a server using the specified address.
If wait is true, Connect will wait until the connection completes. Warning: This will block the GUI.
If wait is false, Connect will try to establish the connection and return immediately, without blocking the GUI. When used this way, even if Connect returns false, the connection request can be completed later. To detect this, use WaitOnConnect, or catch wxSOCKET_CONNECTION events (for successful establishment) and wxSOCKET_LOST events (for connection failure).
Code: Select all
socket->Connect(server,true);
Code: Select all
socket->Connect(server, false);
-Scott
wxMSW 2.6.2, VS 2002, 2003 and 2005, Code::Blocks and mingw, Windows XP Pro