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:
Vadim Zeitlin
2000-03-15 19:19:44 +00:00
parent 669f7a111f
commit 8dfea369ea
6 changed files with 510 additions and 481 deletions

886
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1008,12 +1008,7 @@ dnl ---------------------------------------------------------------------------
WX_ARG_ENABLE(intl, [ --enable-intl use internationalization system], wxUSE_INTL)
WX_ARG_ENABLE(config, [ --enable-config use wxConfig (and derived) classes], wxUSE_CONFIG)
dnl can't use sockets without GUI so far
if test "$wxUSE_GUI" = "yes"; then
WX_ARG_ENABLE(sockets, [ --enable-sockets use socket/network classes], wxUSE_SOCKETS)
else
wxUSE_SOCKETS=no
fi
WX_ARG_ENABLE(dialupman, [ --enable-dialupman use dialup network classes], wxUSE_DIALUP_MANAGER)
WX_ARG_ENABLE(ipc, [ --enable-ipc use interprocess communication (wxSocket etc.)], wxUSE_IPC)

View File

@@ -137,13 +137,13 @@ framecmn.cpp C
fs_inet.cpp C B
fs_zip.cpp C B
fs_mem.cpp C B
ftp.cpp C S
ftp.cpp C S,B
gdicmn.cpp C
geometry.cpp C
gifdecod.cpp C
hash.cpp C B
helpbase.cpp C
http.cpp C S
http.cpp C S,B
imagbmp.cpp C
image.cpp C
imagall.cpp C
@@ -155,7 +155,7 @@ imagpng.cpp C 32
imagpnm.cpp C 32
init.cpp B
intl.cpp C B
ipcbase.cpp C
ipcbase.cpp C B
layout.cpp C
lboxcmn.cpp C
list.cpp C B
@@ -172,15 +172,15 @@ odbc.cpp C R,X,P
paper.cpp C
prntbase.cpp C
process.cpp C 32,B
protocol.cpp C S
protocol.cpp C S,B
resource.cpp C
sckaddr.cpp C S
sckfile.cpp C S
sckipc.cpp C S
sckstrm.cpp C S
sckaddr.cpp C S,B
sckfile.cpp C S,B
sckipc.cpp C S,B
sckstrm.cpp C S,B
serbase.cpp C B
sizer.cpp C
socket.cpp C S
socket.cpp C S,B
stream.cpp C B
strconv.cpp C B
string.cpp C B
@@ -191,7 +191,7 @@ timercmn.cpp C B
tokenzr.cpp C B
txtstrm.cpp C B
unzip.c C B
url.cpp C S
url.cpp C S,B
utilscmn.cpp C B
valgen.cpp C
validate.cpp C
@@ -204,7 +204,7 @@ wxexpr.cpp C
zipstrm.cpp C B
zstream.cpp C B
gsocket.c M S
gsocket.c M S,B
gsockmsw.c M S
accel.cpp M
app.cpp M
@@ -316,7 +316,7 @@ fontutil.cpp U
mimetype.cpp U B
threadpsx.cpp U B
utilsunx.cpp U B
gsocket.c U
gsocket.c U B
mimetype.cpp U B
gsockgtk.c R

View File

@@ -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)

View File

@@ -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

View File

@@ -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);