// --------------------------------------------------------------------------
#if defined(__GNUG__) && !defined(__APPLE__)
-# pragma implementation "client.cpp"
-# pragma interface "client.cpp"
+ #pragma implementation
+ #pragma interface
#endif
// For compilers that support precompilation, includes "wx/wx.h".
# pragma hdrstop
#endif
-// for all others, include the necessary headers
+// for all others, include the necessary headers
#ifndef WX_PRECOMP
# include "wx/wx.h"
#endif
void OnTest3(wxCommandEvent& event);
void OnCloseConnection(wxCommandEvent& event);
+#if wxUSE_URL
// event handlers for Protocols menu
void OnTestURL(wxCommandEvent& event);
+#endif
// event handlers for DatagramSocket menu (stub)
void OnDatagram(wxCommandEvent& event);
enum
{
// menu items
- CLIENT_QUIT = 1000,
- CLIENT_ABOUT,
- CLIENT_OPEN,
+ CLIENT_QUIT = wxID_EXIT,
+ CLIENT_ABOUT = wxID_ABOUT,
+ CLIENT_OPEN = 100,
CLIENT_TEST1,
CLIENT_TEST2,
CLIENT_TEST3,
CLIENT_CLOSE,
+#if wxUSE_URL
CLIENT_TESTURL,
+#endif
CLIENT_DGRAM,
// id for socket
EVT_MENU(CLIENT_TEST3, MyFrame::OnTest3)
EVT_MENU(CLIENT_CLOSE, MyFrame::OnCloseConnection)
EVT_MENU(CLIENT_DGRAM, MyFrame::OnDatagram)
+#if wxUSE_URL
EVT_MENU(CLIENT_TESTURL, MyFrame::OnTestURL)
+#endif
EVT_SOCKET(SOCKET_ID, MyFrame::OnSocketEvent)
END_EVENT_TABLE()
m_menuDatagramSocket = new wxMenu();
m_menuDatagramSocket->Append(CLIENT_DGRAM, _("Send Datagram"), _("Test UDP sockets"));
+#if wxUSE_URL
m_menuProtocols = new wxMenu();
m_menuProtocols->Append(CLIENT_TESTURL, _("Test URL"), _("Get data from the specified URL"));
+#endif
// Append menus to the menubar
m_menuBar = new wxMenuBar();
m_menuBar->Append(m_menuFile, _("&File"));
m_menuBar->Append(m_menuSocket, _("&SocketClient"));
m_menuBar->Append(m_menuDatagramSocket, _("&DatagramSocket"));
+#if wxUSE_URL
m_menuBar->Append(m_menuProtocols, _("&Protocols"));
+#endif
SetMenuBar(m_menuBar);
#if wxUSE_STATUSBAR
//
// Connect(addr, false) will issue a nonblocking connection request
// and return immediately. If the return value is true, then the
- // connection has been already succesfully established. If it is
+ // connection has been already successfully established. If it is
// false, you must wait for the request to complete, either with
// WaitOnConnect() or by watching wxSOCKET_CONNECTION / LOST
// events (please read the documentation).
// // update waitmore if needed.
// }
// bool success = client->IsConnected();
- //
+ //
// And that's all :-)
m_text->AppendText(_("\nTrying to connect (timeout = 10 sec) ...\n"));
m_text->AppendText(_("Failed ! Unable to connect\n"));
wxMessageBox(_("Can't connect to the specified host"), _("Alert !"));
}
-
+
UpdateStatusBar();
}
m_sock->SetFlags(wxSOCKET_WAITALL);
buf1 = _("Test string (less than 256 chars!)");
- len = (wxStrlen(buf1) + 1) * sizeof(wxChar);
+ len = (unsigned char)((wxStrlen(buf1) + 1) * sizeof(wxChar));
buf2 = new wxChar[wxStrlen(buf1) + 1];
m_text->AppendText(_("Sending a test buffer to the server ..."));
m_text->AppendText(_("Comparing the two buffers ..."));
if (memcmp(msg1, msg2, len) != 0)
{
- m_text->AppendText(_("failed!\n"));
+ m_text->AppendText(_("failed!\n"));
m_text->AppendText(_("Test 2 failed !\n"));
}
else
m_text->AppendText(_("=== Datagram test ends ===\n"));
}
+#if wxUSE_URL
+
void MyFrame::OnTestURL(wxCommandEvent& WXUNUSED(event))
{
// Note that we are creating a new socket here, so this
wxYield();
// Get the data
- wxFile fileTest(wxT("test.url"));
+ wxFile fileTest(wxT("test.url"), wxFile::write);
wxFileOutputStream sout(fileTest);
if (!sout.Ok())
{
delete data;
}
+#endif
+
void MyFrame::OnSocketEvent(wxSocketEvent& event)
{
wxString s = _("OnSocketEvent: ");