wxSocketServer test added to console sample
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6741 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -299,9 +299,6 @@ void MyFrame::OnAllowYearUpdate(wxUpdateUIEvent& event)
|
||||
MyPanel::MyPanel(wxFrame *frame)
|
||||
: wxPanel(frame, -1)
|
||||
{
|
||||
// using constraints doesn't work under GTK - the calendar window is never
|
||||
// repainted after it had been moved at least once!
|
||||
#if 1
|
||||
SetAutoLayout(TRUE);
|
||||
|
||||
wxString date;
|
||||
@@ -331,19 +328,6 @@ MyPanel::MyPanel(wxFrame *frame)
|
||||
c->width.AsIs();
|
||||
|
||||
m_calendar->SetConstraints(c);
|
||||
#else
|
||||
wxString date;
|
||||
date.Printf("Selected date: %s",
|
||||
wxDateTime::Today().FormatISODate().c_str());
|
||||
m_date = new wxStaticText(this, -1, date, wxPoint(10, 100));
|
||||
m_calendar = new wxCalendarCtrl(this, Calendar_CalCtrl,
|
||||
wxDefaultDateTime,
|
||||
wxPoint(200, 20),
|
||||
wxDefaultSize,
|
||||
wxCAL_MONDAY_FIRST |
|
||||
wxCAL_SHOW_HOLIDAYS |
|
||||
wxRAISED_BORDER);
|
||||
#endif
|
||||
}
|
||||
|
||||
void MyPanel::OnCalendar(wxCalendarEvent& event)
|
||||
|
@@ -732,6 +732,59 @@ static void TestSocketServer()
|
||||
{
|
||||
puts("ERROR: failed to bind");
|
||||
}
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
puts("Server: waiting for connection...");
|
||||
|
||||
wxSocketBase *socket = server->Accept();
|
||||
if ( !socket )
|
||||
{
|
||||
puts("ERROR: wxSocketServer::Accept() failed.");
|
||||
break;
|
||||
}
|
||||
|
||||
puts("Server: got a client.");
|
||||
|
||||
wxString s;
|
||||
char ch = '\0';
|
||||
for ( ;; )
|
||||
{
|
||||
if ( socket->Read(&ch, sizeof(ch)).Error() )
|
||||
{
|
||||
puts("ERROR: in wxSocket::Read.");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ch == '\r' )
|
||||
continue;
|
||||
|
||||
if ( ch == '\n' )
|
||||
break;
|
||||
|
||||
s += ch;
|
||||
}
|
||||
|
||||
if ( ch != '\n' )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Server: got '%s'.\n", s.c_str());
|
||||
if ( s == _T("bye") )
|
||||
{
|
||||
delete socket;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
socket->Write(s.MakeUpper().c_str(), s.length());
|
||||
socket->Write("\r\n", 2);
|
||||
printf("Server: wrote '%s'.\n", s.c_str());
|
||||
|
||||
delete socket;
|
||||
}
|
||||
}
|
||||
|
||||
static void TestSocketClient()
|
||||
@@ -2553,12 +2606,13 @@ int main(int argc, char **argv)
|
||||
#endif // TEST_MIME
|
||||
|
||||
#ifdef TEST_SOCKETS
|
||||
if ( 1 )
|
||||
TestSocketServer();
|
||||
if ( 0 )
|
||||
{
|
||||
TestSocketServer();
|
||||
TestSocketClient();
|
||||
}
|
||||
TestProtocolFtp();
|
||||
}
|
||||
#endif // TEST_SOCKETS
|
||||
|
||||
#ifdef TEST_TIMER
|
||||
|
@@ -543,7 +543,7 @@ void MyFrame::OnTestURL(wxCommandEvent& WXUNUSED(event))
|
||||
m_text->AppendText(_("\n=== URL test begins ===\n"));
|
||||
wxString urlname = wxGetTextFromUser(_("Enter an URL to get"),
|
||||
_("URL:"),
|
||||
_("http://localhost"));
|
||||
_T("http://localhost"));
|
||||
|
||||
// Parse the URL
|
||||
wxURL url(urlname);
|
||||
|
Reference in New Issue
Block a user