+ wxSocketBase *sock = event.Socket();
+ wxString s = _T("OnSocketEvent: ");
+
+ // We first print a msg
+ switch(event.SocketEvent())
+ {
+ case wxSOCKET_INPUT: s.Append(_T("wxSOCKET_INPUT\n")); break;
+ case wxSOCKET_LOST: s.Append(_T("wxSOCKET_LOST\n")); break;
+ default: s.Append(_T("unexpected event !\n"));
+ }
+
+ m_text->AppendText(s);
+
+ // Now we process the event
+ switch(event.SocketEvent())
+ {
+ case wxSOCKET_INPUT:
+ {
+ // We disable input events, so that the test doesn't trigger
+ // wxSocketEvent again.
+ sock->SetNotify(wxSOCKET_LOST_FLAG);
+
+ // Which test are we going to run?
+ unsigned char c;
+ sock->Read((char *)&c ,1);
+
+ switch (c)
+ {
+ case 0xBE: Test1(sock); break;
+ case 0xCE: Test2(sock); break;
+ case 0xDE: Test3(sock); break;
+ default: s.Append(_T("Unknown test id received from client\n"));
+ }
+
+ // Enable input events again.
+ sock->SetNotify(wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG);
+ break;
+ }
+ case wxSOCKET_LOST:
+ {
+ m_numClients--;
+
+ // We cannot delete the socket right now because we can
+ // be in the middle of a test or something. So we append
+ // it to the list of objects to be deleted.
+ m_text->AppendText(_T("Deleting socket.\n"));
+ wxPendingDelete.Append(sock);
+ break;
+ }
+ default: ;
+ }