+ // Give the frame an icon
+ SetIcon(wxICON(mondrian));
+
+ // Make menus
+ m_menuFile = new wxMenu();
+ m_menuFile->Append(SERVER_ABOUT, _T("&About...\tCtrl-A"), _T("Show about dialog"));
+ m_menuFile->AppendSeparator();
+ m_menuFile->Append(SERVER_QUIT, _T("E&xit\tAlt-X"), _T("Quit server"));
+
+ // Append menus to the menubar
+ m_menuBar = new wxMenuBar();
+ m_menuBar->Append(m_menuFile, _T("&File"));
+ SetMenuBar(m_menuBar);
+
+ // Status bar
+ CreateStatusBar(2);
+
+ // Make a panel with a textctrl in it
+ m_panel = new wxPanel(this, -1, wxPoint(0, 0), GetClientSize());
+ m_text = new wxTextCtrl(m_panel, -1,
+ _T("Welcome to wxSocket demo: Server\n"),
+ wxPoint(0, 0), m_panel->GetClientSize(),
+ wxTE_MULTILINE | wxTE_READONLY);
+
+ // Create the socket
+ wxIPV4address addr;
+ addr.Service(3000);
+ addr.LocalHost();
+
+ m_server = new wxSocketServer(addr);
+ m_server->SetEventHandler(*this, SERVER_ID);
+ m_server->SetNotify(wxSOCKET_CONNECTION_FLAG);
+ m_server->Notify(TRUE);
+
+ // We use Ok() here to see if the server is really listening
+ if (m_server->Ok())
+ m_text->AppendText(_T("Server listening.\n\n"));
+ else
+ m_text->AppendText(_T("Could not listen at the specified port !\n\n"));
+
+ m_busy = FALSE;
+ m_numClients = 0;
+ UpdateStatusBar();
+}