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