]> git.saurik.com Git - wxWidgets.git/blob - samples/sockets/client.cpp
Add support for the Windows Testdrive machines and other improvements.
[wxWidgets.git] / samples / sockets / client.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: client.cpp
3 // Purpose: Client for wxSocket demo
4 // Author: Guillermo Rodriguez Garcia <guille@iies.es>
5 // Modified by:
6 // Created: 1999/09/19
7 // RCS-ID: $Id$
8 // Copyright: (c) 1999 Guillermo Rodriguez Garcia
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ==========================================================================
13 // declarations
14 // ==========================================================================
15
16 // --------------------------------------------------------------------------
17 // headers
18 // --------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx/wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 # pragma hdrstop
25 #endif
26
27 // for all others, include the necessary headers
28 #ifndef WX_PRECOMP
29 # include "wx/wx.h"
30 #endif
31
32 #include "wx/socket.h"
33 #include "wx/url.h"
34 #include "wx/wfstream.h"
35
36 // --------------------------------------------------------------------------
37 // resources
38 // --------------------------------------------------------------------------
39
40 // the application icon
41 #if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__)
42 # include "mondrian.xpm"
43 #endif
44
45 // --------------------------------------------------------------------------
46 // classes
47 // --------------------------------------------------------------------------
48
49 // Define a new application type
50 class MyApp : public wxApp
51 {
52 public:
53 virtual bool OnInit();
54 };
55
56 // Define a new frame type: this is going to be our main frame
57 class MyFrame : public wxFrame
58 {
59 public:
60 MyFrame();
61 ~MyFrame();
62
63 // event handlers for File menu
64 void OnQuit(wxCommandEvent& event);
65 void OnAbout(wxCommandEvent& event);
66
67 // event handlers for Socket menu
68 void OnOpenConnection(wxCommandEvent& event);
69 void OnTest1(wxCommandEvent& event);
70 void OnTest2(wxCommandEvent& event);
71 void OnTest3(wxCommandEvent& event);
72 void OnCloseConnection(wxCommandEvent& event);
73
74 #if wxUSE_URL
75 // event handlers for Protocols menu
76 void OnTestURL(wxCommandEvent& event);
77 #endif
78 #if wxUSE_IPV6
79 void OnOpenConnectionIPv6(wxCommandEvent& event);
80 #endif
81
82 void OpenConnection(int family = AF_INET);
83
84 // event handlers for DatagramSocket menu (stub)
85 void OnDatagram(wxCommandEvent& event);
86
87 // socket event handler
88 void OnSocketEvent(wxSocketEvent& event);
89
90 // convenience functions
91 void UpdateStatusBar();
92
93 private:
94 wxSocketClient *m_sock;
95 wxTextCtrl *m_text;
96 wxMenu *m_menuFile;
97 wxMenu *m_menuSocket;
98 wxMenu *m_menuDatagramSocket;
99 wxMenu *m_menuProtocols;
100 wxMenuBar *m_menuBar;
101 bool m_busy;
102
103 // any class wishing to process wxWidgets events must use this macro
104 DECLARE_EVENT_TABLE()
105 };
106
107 // --------------------------------------------------------------------------
108 // constants
109 // --------------------------------------------------------------------------
110
111 // IDs for the controls and the menu commands
112 enum
113 {
114 // menu items
115 CLIENT_QUIT = wxID_EXIT,
116 CLIENT_ABOUT = wxID_ABOUT,
117 CLIENT_OPEN = 100,
118 #if wxUSE_IPV6
119 CLIENT_OPENIPV6,
120 #endif
121 CLIENT_TEST1,
122 CLIENT_TEST2,
123 CLIENT_TEST3,
124 CLIENT_CLOSE,
125 #if wxUSE_URL
126 CLIENT_TESTURL,
127 #endif
128 CLIENT_DGRAM,
129
130 // id for socket
131 SOCKET_ID
132 };
133
134 // --------------------------------------------------------------------------
135 // event tables and other macros for wxWidgets
136 // --------------------------------------------------------------------------
137
138 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
139 EVT_MENU(CLIENT_QUIT, MyFrame::OnQuit)
140 EVT_MENU(CLIENT_ABOUT, MyFrame::OnAbout)
141 EVT_MENU(CLIENT_OPEN, MyFrame::OnOpenConnection)
142 #if wxUSE_IPV6
143 EVT_MENU(CLIENT_OPENIPV6, MyFrame::OnOpenConnectionIPv6)
144 #endif
145 EVT_MENU(CLIENT_TEST1, MyFrame::OnTest1)
146 EVT_MENU(CLIENT_TEST2, MyFrame::OnTest2)
147 EVT_MENU(CLIENT_TEST3, MyFrame::OnTest3)
148 EVT_MENU(CLIENT_CLOSE, MyFrame::OnCloseConnection)
149 EVT_MENU(CLIENT_DGRAM, MyFrame::OnDatagram)
150 #if wxUSE_URL
151 EVT_MENU(CLIENT_TESTURL, MyFrame::OnTestURL)
152 #endif
153 EVT_SOCKET(SOCKET_ID, MyFrame::OnSocketEvent)
154 END_EVENT_TABLE()
155
156 IMPLEMENT_APP(MyApp)
157
158 // ==========================================================================
159 // implementation
160 // ==========================================================================
161
162 // --------------------------------------------------------------------------
163 // the application class
164 // --------------------------------------------------------------------------
165
166 bool MyApp::OnInit()
167 {
168 if ( !wxApp::OnInit() )
169 return false;
170
171 // Create the main application window
172 MyFrame *frame = new MyFrame();
173
174 // Show it and tell the application that it's our main window
175 frame->Show(true);
176 SetTopWindow(frame);
177
178 // success
179 return true;
180 }
181
182 // --------------------------------------------------------------------------
183 // main frame
184 // --------------------------------------------------------------------------
185
186 // frame constructor
187 MyFrame::MyFrame() : wxFrame((wxFrame *)NULL, wxID_ANY,
188 _("wxSocket demo: Client"),
189 wxDefaultPosition, wxSize(300, 200))
190 {
191 // Give the frame an icon
192 SetIcon(wxICON(mondrian));
193
194 // Make menus
195 m_menuFile = new wxMenu();
196 m_menuFile->Append(CLIENT_ABOUT, _("&About...\tCtrl-A"), _("Show about dialog"));
197 m_menuFile->AppendSeparator();
198 m_menuFile->Append(CLIENT_QUIT, _("E&xit\tAlt-X"), _("Quit client"));
199
200 m_menuSocket = new wxMenu();
201 m_menuSocket->Append(CLIENT_OPEN, _("&Open session"), _("Connect to server"));
202 #if wxUSE_IPV6
203 m_menuSocket->Append(CLIENT_OPENIPV6, _("&Open session(IPv6)"), _("Connect to server(IPv6)"));
204 #endif
205 m_menuSocket->AppendSeparator();
206 m_menuSocket->Append(CLIENT_TEST1, _("Test &1"), _("Test basic functionality"));
207 m_menuSocket->Append(CLIENT_TEST2, _("Test &2"), _("Test ReadMsg and WriteMsg"));
208 m_menuSocket->Append(CLIENT_TEST3, _("Test &3"), _("Test large data transfer"));
209 m_menuSocket->AppendSeparator();
210 m_menuSocket->Append(CLIENT_CLOSE, _("&Close session"), _("Close connection"));
211
212 m_menuDatagramSocket = new wxMenu();
213 m_menuDatagramSocket->Append(CLIENT_DGRAM, _("Send Datagram"), _("Test UDP sockets"));
214
215 #if wxUSE_URL
216 m_menuProtocols = new wxMenu();
217 m_menuProtocols->Append(CLIENT_TESTURL, _("Test URL"), _("Get data from the specified URL"));
218 #endif
219
220 // Append menus to the menubar
221 m_menuBar = new wxMenuBar();
222 m_menuBar->Append(m_menuFile, _("&File"));
223 m_menuBar->Append(m_menuSocket, _("&SocketClient"));
224 m_menuBar->Append(m_menuDatagramSocket, _("&DatagramSocket"));
225 #if wxUSE_URL
226 m_menuBar->Append(m_menuProtocols, _("&Protocols"));
227 #endif
228 SetMenuBar(m_menuBar);
229
230 #if wxUSE_STATUSBAR
231 // Status bar
232 CreateStatusBar(2);
233 #endif // wxUSE_STATUSBAR
234
235 // Make a textctrl for logging
236 m_text = new wxTextCtrl(this, wxID_ANY,
237 _("Welcome to wxSocket demo: Client\nClient ready\n"),
238 wxDefaultPosition, wxDefaultSize,
239 wxTE_MULTILINE | wxTE_READONLY);
240
241 // Create the socket
242 m_sock = new wxSocketClient();
243
244 // Setup the event handler and subscribe to most events
245 m_sock->SetEventHandler(*this, SOCKET_ID);
246 m_sock->SetNotify(wxSOCKET_CONNECTION_FLAG |
247 wxSOCKET_INPUT_FLAG |
248 wxSOCKET_LOST_FLAG);
249 m_sock->Notify(true);
250
251 m_busy = false;
252 UpdateStatusBar();
253 }
254
255 MyFrame::~MyFrame()
256 {
257 // No delayed deletion here, as the frame is dying anyway
258 delete m_sock;
259 }
260
261 // event handlers
262
263 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
264 {
265 // true is to force the frame to close
266 Close(true);
267 }
268
269 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
270 {
271 wxMessageBox(_("wxSocket demo: Client\n(c) 1999 Guillermo Rodriguez Garcia\n"),
272 _("About Client"),
273 wxOK | wxICON_INFORMATION, this);
274 }
275
276 void MyFrame::OnOpenConnection(wxCommandEvent& WXUNUSED(event))
277 {
278 OpenConnection(AF_INET);
279 }
280 #if wxUSE_IPV6
281 void MyFrame::OnOpenConnectionIPv6(wxCommandEvent& WXUNUSED(event))
282 {
283 OpenConnection(AF_INET6);
284 }
285 #endif // wxUSE_IPV6
286
287 void MyFrame::OpenConnection(int family)
288 {
289 wxIPaddress * addr;
290 wxIPV4address addr4;
291 #if wxUSE_IPV6
292 wxIPV6address addr6;
293 if ( family==AF_INET6 )
294 addr = &addr6;
295 else
296 addr = &addr4;
297 #else
298 wxUnusedVar(family);
299 addr = &addr4;
300 #endif
301
302 m_menuSocket->Enable(CLIENT_OPEN, false);
303 #if wxUSE_IPV6
304 m_menuSocket->Enable(CLIENT_OPENIPV6, false);
305 #endif
306 m_menuSocket->Enable(CLIENT_CLOSE, false);
307
308 // Ask user for server address
309 wxString hostname = wxGetTextFromUser(
310 _("Enter the address of the wxSocket demo server:"),
311 _("Connect ..."),
312 _("localhost"));
313
314 addr->Hostname(hostname);
315 addr->Service(3000);
316
317 // Mini-tutorial for Connect() :-)
318 // ---------------------------
319 //
320 // There are two ways to use Connect(): blocking and non-blocking,
321 // depending on the value passed as the 'wait' (2nd) parameter.
322 //
323 // Connect(addr, true) will wait until the connection completes,
324 // returning true on success and false on failure. This call blocks
325 // the GUI (this might be changed in future releases to honour the
326 // wxSOCKET_BLOCK flag).
327 //
328 // Connect(addr, false) will issue a nonblocking connection request
329 // and return immediately. If the return value is true, then the
330 // connection has been already successfully established. If it is
331 // false, you must wait for the request to complete, either with
332 // WaitOnConnect() or by watching wxSOCKET_CONNECTION / LOST
333 // events (please read the documentation).
334 //
335 // WaitOnConnect() itself never blocks the GUI (this might change
336 // in the future to honour the wxSOCKET_BLOCK flag). This call will
337 // return false on timeout, or true if the connection request
338 // completes, which in turn might mean:
339 //
340 // a) That the connection was successfully established
341 // b) That the connection request failed (for example, because
342 // it was refused by the peer.
343 //
344 // Use IsConnected() to distinguish between these two.
345 //
346 // So, in a brief, you should do one of the following things:
347 //
348 // For blocking Connect:
349 //
350 // bool success = client->Connect(addr, true);
351 //
352 // For nonblocking Connect:
353 //
354 // client->Connect(addr, false);
355 //
356 // bool waitmore = true;
357 // while (! client->WaitOnConnect(seconds, millis) && waitmore )
358 // {
359 // // possibly give some feedback to the user,
360 // // update waitmore if needed.
361 // }
362 // bool success = client->IsConnected();
363 //
364 // And that's all :-)
365
366 m_text->AppendText(_("\nTrying to connect (timeout = 10 sec) ...\n"));
367 m_sock->Connect(*addr, false);
368 m_sock->WaitOnConnect(10);
369
370 if (m_sock->IsConnected())
371 m_text->AppendText(_("Succeeded ! Connection established\n"));
372 else
373 {
374 m_sock->Close();
375 m_text->AppendText(_("Failed ! Unable to connect\n"));
376 wxMessageBox(_("Can't connect to the specified host"), _("Alert !"));
377 }
378
379 UpdateStatusBar();
380 }
381
382 void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
383 {
384 // Disable socket menu entries (exception: Close Session)
385 m_busy = true;
386 UpdateStatusBar();
387
388 m_text->AppendText(_("\n=== Test 1 begins ===\n"));
389
390 // Tell the server which test we are running
391 unsigned char c = 0xBE;
392 m_sock->Write(&c, 1);
393
394 // Send some data and read it back. We know the size of the
395 // buffer, so we can specify the exact number of bytes to be
396 // sent or received and use the wxSOCKET_WAITALL flag. Also,
397 // we have disabled menu entries which could interfere with
398 // the test, so we can safely avoid the wxSOCKET_BLOCK flag.
399 //
400 // First we send a byte with the length of the string, then
401 // we send the string itself (do NOT try to send any integral
402 // value larger than a byte "as is" across the network, or
403 // you might be in trouble! Ever heard about big and little
404 // endian computers?)
405
406 m_sock->SetFlags(wxSOCKET_WAITALL);
407
408 const wxChar *buf1 = _T("Test string (less than 256 chars!)");
409 unsigned char len = (unsigned char)((wxStrlen(buf1) + 1)*sizeof(wxChar));
410 wxChar *buf2 = new wxChar[wxStrlen(buf1) + 1];
411
412 m_text->AppendText(_("Sending a test buffer to the server ..."));
413 m_sock->Write(&len, 1);
414 m_sock->Write(buf1, len);
415 m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
416
417 m_text->AppendText(_("Receiving the buffer back from server ..."));
418 m_sock->Read(buf2, len);
419 m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
420
421 m_text->AppendText(_("Comparing the two buffers ..."));
422 if (memcmp(buf1, buf2, len) != 0)
423 {
424 m_text->AppendText(_("failed!\n"));
425 m_text->AppendText(_("Test 1 failed !\n"));
426 }
427 else
428 {
429 m_text->AppendText(_("done\n"));
430 m_text->AppendText(_("Test 1 passed !\n"));
431 }
432 m_text->AppendText(_("=== Test 1 ends ===\n"));
433
434 delete[] buf2;
435 m_busy = false;
436 UpdateStatusBar();
437 }
438
439 void MyFrame::OnTest2(wxCommandEvent& WXUNUSED(event))
440 {
441 const wxChar *msg1;
442 wxChar *msg2;
443 size_t len;
444
445 // Disable socket menu entries (exception: Close Session)
446 m_busy = true;
447 UpdateStatusBar();
448
449 m_text->AppendText(_("\n=== Test 2 begins ===\n"));
450
451 // Tell the server which test we are running
452 unsigned char c = 0xCE;
453 m_sock->Write(&c, 1);
454
455 // Here we use ReadMsg and WriteMsg to send messages with
456 // a header with size information. Also, the reception is
457 // event triggered, so we test input events as well.
458 //
459 // We need to set no flags here (ReadMsg and WriteMsg are
460 // not affected by flags)
461
462 m_sock->SetFlags(wxSOCKET_WAITALL);
463
464 wxString s = wxGetTextFromUser(
465 _("Enter an arbitrary string to send to the server:"),
466 _("Test 2 ..."),
467 _("Yes I like wxWidgets!"));
468
469 msg1 = s.c_str();
470 len = (wxStrlen(msg1) + 1) * sizeof(wxChar);
471 msg2 = new wxChar[wxStrlen(msg1) + 1];
472
473 m_text->AppendText(_("Sending the string with WriteMsg ..."));
474 m_sock->WriteMsg(msg1, len);
475 m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
476 m_text->AppendText(_("Waiting for an event (timeout = 2 sec)\n"));
477
478 // Wait until data available (will also return if the connection is lost)
479 m_sock->WaitForRead(2);
480
481 if (m_sock->IsData())
482 {
483 m_text->AppendText(_("Reading the string back with ReadMsg ..."));
484 m_sock->ReadMsg(msg2, len);
485 m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
486 m_text->AppendText(_("Comparing the two buffers ..."));
487 if (memcmp(msg1, msg2, len) != 0)
488 {
489 m_text->AppendText(_("failed!\n"));
490 m_text->AppendText(_("Test 2 failed !\n"));
491 }
492 else
493 {
494 m_text->AppendText(_("done\n"));
495 m_text->AppendText(_("Test 2 passed !\n"));
496 }
497 }
498 else
499 m_text->AppendText(_("Timeout ! Test 2 failed.\n"));
500
501 m_text->AppendText(_("=== Test 2 ends ===\n"));
502
503 delete[] msg2;
504 m_busy = false;
505 UpdateStatusBar();
506 }
507
508 void MyFrame::OnTest3(wxCommandEvent& WXUNUSED(event))
509 {
510 char *buf1;
511 char *buf2;
512 unsigned char len;
513
514 // Disable socket menu entries (exception: Close Session)
515 m_busy = true;
516 UpdateStatusBar();
517
518 m_text->AppendText(_("\n=== Test 3 begins ===\n"));
519
520 // Tell the server which test we are running
521 unsigned char c = 0xDE;
522 m_sock->Write(&c, 1);
523
524 // This test also is similar to the first one but it sends a
525 // large buffer so that wxSocket is actually forced to split
526 // it into pieces and take care of sending everything before
527 // returning.
528
529 m_sock->SetFlags(wxSOCKET_WAITALL);
530
531 // Note that len is in kbytes here!
532 len = 32;
533 buf1 = new char[len * 1024];
534 buf2 = new char[len * 1024];
535
536 for (int i = 0; i < len * 1024; i ++)
537 buf1[i] = (char)(i % 256);
538
539 m_text->AppendText(_("Sending a large buffer (32K) to the server ..."));
540 m_sock->Write(&len, 1);
541 m_sock->Write(buf1, len * 1024);
542 m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
543
544 m_text->AppendText(_("Receiving the buffer back from server ..."));
545 m_sock->Read(buf2, len * 1024);
546 m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
547
548 m_text->AppendText(_("Comparing the two buffers ..."));
549 if (memcmp(buf1, buf2, len) != 0)
550 {
551 m_text->AppendText(_("failed!\n"));
552 m_text->AppendText(_("Test 3 failed !\n"));
553 }
554 else
555 {
556 m_text->AppendText(_("done\n"));
557 m_text->AppendText(_("Test 3 passed !\n"));
558 }
559 m_text->AppendText(_("=== Test 3 ends ===\n"));
560
561 delete[] buf2;
562 m_busy = false;
563 UpdateStatusBar();
564 }
565
566 void MyFrame::OnCloseConnection(wxCommandEvent& WXUNUSED(event))
567 {
568 m_sock->Close();
569 UpdateStatusBar();
570 }
571
572 void MyFrame::OnDatagram(wxCommandEvent& WXUNUSED(event))
573 {
574 m_text->AppendText(_("\n=== Datagram test begins ===\n"));
575 m_text->AppendText(_("Sorry, not implemented\n"));
576 m_text->AppendText(_("=== Datagram test ends ===\n"));
577 }
578
579 #if wxUSE_URL
580
581 void MyFrame::OnTestURL(wxCommandEvent& WXUNUSED(event))
582 {
583 // Note that we are creating a new socket here, so this
584 // won't mess with the client/server demo.
585
586 // Ask for the URL
587 m_text->AppendText(_("\n=== URL test begins ===\n"));
588 wxString urlname = wxGetTextFromUser(_("Enter an URL to get"),
589 _("URL:"),
590 _T("http://localhost"));
591
592 // Parse the URL
593 wxURL url(urlname);
594 if (url.GetError() != wxURL_NOERR)
595 {
596 m_text->AppendText(_("Error: couldn't parse URL\n"));
597 m_text->AppendText(_("=== URL test ends ===\n"));
598 return;
599 }
600
601 // Try to get the input stream (connects to the given URL)
602 m_text->AppendText(_("Trying to establish connection...\n"));
603 wxYield();
604 wxInputStream *data = url.GetInputStream();
605 if (!data)
606 {
607 m_text->AppendText(_("Error: couldn't read from URL\n"));
608 m_text->AppendText(_("=== URL test ends ===\n"));
609 return;
610 }
611
612 // Print the contents type and file size
613 wxString s;
614 s.Printf(_("Contents type: %s\nFile size: %i\nStarting to download...\n"),
615 url.GetProtocol().GetContentType().c_str(),
616 data->GetSize());
617 m_text->AppendText(s);
618 wxYield();
619
620 // Get the data
621 wxFile fileTest(wxT("test.url"), wxFile::write);
622 wxFileOutputStream sout(fileTest);
623 if (!sout.Ok())
624 {
625 m_text->AppendText(_("Error: couldn't open file for output\n"));
626 m_text->AppendText(_("=== URL test ends ===\n"));
627 return;
628 }
629
630 data->Read(sout);
631 m_text->AppendText(_("Results written to file: test.url\n"));
632 m_text->AppendText(_("Done.\n"));
633 m_text->AppendText(_("=== URL test ends ===\n"));
634
635 delete data;
636 }
637
638 #endif
639
640 void MyFrame::OnSocketEvent(wxSocketEvent& event)
641 {
642 wxString s = _("OnSocketEvent: ");
643
644 switch(event.GetSocketEvent())
645 {
646 case wxSOCKET_INPUT : s.Append(_("wxSOCKET_INPUT\n")); break;
647 case wxSOCKET_LOST : s.Append(_("wxSOCKET_LOST\n")); break;
648 case wxSOCKET_CONNECTION : s.Append(_("wxSOCKET_CONNECTION\n")); break;
649 default : s.Append(_("Unexpected event !\n")); break;
650 }
651
652 m_text->AppendText(s);
653 UpdateStatusBar();
654 }
655
656 // convenience functions
657
658 void MyFrame::UpdateStatusBar()
659 {
660 wxString s;
661
662 if (!m_sock->IsConnected())
663 {
664 s.Printf(_("Not connected"));
665 }
666 else
667 {
668 #if wxUSE_IPV6
669 wxIPV6address addr;
670 #else
671 wxIPV4address addr;
672 #endif
673
674 m_sock->GetPeer(addr);
675 s.Printf(_("%s : %d"), (addr.Hostname()).c_str(), addr.Service());
676 }
677
678 #if wxUSE_STATUSBAR
679 SetStatusText(s, 1);
680 #endif // wxUSE_STATUSBAR
681
682 m_menuSocket->Enable(CLIENT_OPEN, !m_sock->IsConnected() && !m_busy);
683 #if wxUSE_IPV6
684 m_menuSocket->Enable(CLIENT_OPENIPV6, !m_sock->IsConnected() && !m_busy);
685 #endif
686 m_menuSocket->Enable(CLIENT_TEST1, m_sock->IsConnected() && !m_busy);
687 m_menuSocket->Enable(CLIENT_TEST2, m_sock->IsConnected() && !m_busy);
688 m_menuSocket->Enable(CLIENT_TEST3, m_sock->IsConnected() && !m_busy);
689 m_menuSocket->Enable(CLIENT_CLOSE, m_sock->IsConnected());
690 }