]> git.saurik.com Git - wxWidgets.git/blob - samples/sockets/client.cpp
8c336ba34e5c507727eec9c86f91b87cbfba4b5d
[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 #if wxUSE_IPV6
291 wxIPV6address addr6;
292 wxIPV4address addr4;
293 if(family==AF_INET6)
294 {
295 addr = & addr6;
296 } else {
297 addr = & addr4;
298 }
299 #else
300 wxIPV4address addr4;
301 addr = & addr4;
302 #endif
303
304 m_menuSocket->Enable(CLIENT_OPEN, false);
305 #if wxUSE_IPV6
306 m_menuSocket->Enable(CLIENT_OPENIPV6, false);
307 #endif
308 m_menuSocket->Enable(CLIENT_CLOSE, false);
309
310 // Ask user for server address
311 wxString hostname = wxGetTextFromUser(
312 _("Enter the address of the wxSocket demo server:"),
313 _("Connect ..."),
314 _("localhost"));
315
316 addr->Hostname(hostname);
317 addr->Service(3000);
318
319 // Mini-tutorial for Connect() :-)
320 // ---------------------------
321 //
322 // There are two ways to use Connect(): blocking and non-blocking,
323 // depending on the value passed as the 'wait' (2nd) parameter.
324 //
325 // Connect(addr, true) will wait until the connection completes,
326 // returning true on success and false on failure. This call blocks
327 // the GUI (this might be changed in future releases to honour the
328 // wxSOCKET_BLOCK flag).
329 //
330 // Connect(addr, false) will issue a nonblocking connection request
331 // and return immediately. If the return value is true, then the
332 // connection has been already successfully established. If it is
333 // false, you must wait for the request to complete, either with
334 // WaitOnConnect() or by watching wxSOCKET_CONNECTION / LOST
335 // events (please read the documentation).
336 //
337 // WaitOnConnect() itself never blocks the GUI (this might change
338 // in the future to honour the wxSOCKET_BLOCK flag). This call will
339 // return false on timeout, or true if the connection request
340 // completes, which in turn might mean:
341 //
342 // a) That the connection was successfully established
343 // b) That the connection request failed (for example, because
344 // it was refused by the peer.
345 //
346 // Use IsConnected() to distinguish between these two.
347 //
348 // So, in a brief, you should do one of the following things:
349 //
350 // For blocking Connect:
351 //
352 // bool success = client->Connect(addr, true);
353 //
354 // For nonblocking Connect:
355 //
356 // client->Connect(addr, false);
357 //
358 // bool waitmore = true;
359 // while (! client->WaitOnConnect(seconds, millis) && waitmore )
360 // {
361 // // possibly give some feedback to the user,
362 // // update waitmore if needed.
363 // }
364 // bool success = client->IsConnected();
365 //
366 // And that's all :-)
367
368 m_text->AppendText(_("\nTrying to connect (timeout = 10 sec) ...\n"));
369 m_sock->Connect(*addr, false);
370 m_sock->WaitOnConnect(10);
371
372 if (m_sock->IsConnected())
373 m_text->AppendText(_("Succeeded ! Connection established\n"));
374 else
375 {
376 m_sock->Close();
377 m_text->AppendText(_("Failed ! Unable to connect\n"));
378 wxMessageBox(_("Can't connect to the specified host"), _("Alert !"));
379 }
380
381 UpdateStatusBar();
382 }
383
384 void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
385 {
386 // Disable socket menu entries (exception: Close Session)
387 m_busy = true;
388 UpdateStatusBar();
389
390 m_text->AppendText(_("\n=== Test 1 begins ===\n"));
391
392 // Tell the server which test we are running
393 unsigned char c = 0xBE;
394 m_sock->Write(&c, 1);
395
396 // Send some data and read it back. We know the size of the
397 // buffer, so we can specify the exact number of bytes to be
398 // sent or received and use the wxSOCKET_WAITALL flag. Also,
399 // we have disabled menu entries which could interfere with
400 // the test, so we can safely avoid the wxSOCKET_BLOCK flag.
401 //
402 // First we send a byte with the length of the string, then
403 // we send the string itself (do NOT try to send any integral
404 // value larger than a byte "as is" across the network, or
405 // you might be in trouble! Ever heard about big and little
406 // endian computers?)
407
408 m_sock->SetFlags(wxSOCKET_WAITALL);
409
410 const wxChar *buf1 = _T("Test string (less than 256 chars!)");
411 unsigned char len = (unsigned char)((wxStrlen(buf1) + 1)*sizeof(wxChar));
412 wxChar *buf2 = new wxChar[wxStrlen(buf1) + 1];
413
414 m_text->AppendText(_("Sending a test buffer to the server ..."));
415 m_sock->Write(&len, 1);
416 m_sock->Write(buf1, len);
417 m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
418
419 m_text->AppendText(_("Receiving the buffer back from server ..."));
420 m_sock->Read(buf2, len);
421 m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
422
423 m_text->AppendText(_("Comparing the two buffers ..."));
424 if (memcmp(buf1, buf2, len) != 0)
425 {
426 m_text->AppendText(_("failed!\n"));
427 m_text->AppendText(_("Test 1 failed !\n"));
428 }
429 else
430 {
431 m_text->AppendText(_("done\n"));
432 m_text->AppendText(_("Test 1 passed !\n"));
433 }
434 m_text->AppendText(_("=== Test 1 ends ===\n"));
435
436 delete[] buf2;
437 m_busy = false;
438 UpdateStatusBar();
439 }
440
441 void MyFrame::OnTest2(wxCommandEvent& WXUNUSED(event))
442 {
443 const wxChar *msg1;
444 wxChar *msg2;
445 size_t len;
446
447 // Disable socket menu entries (exception: Close Session)
448 m_busy = true;
449 UpdateStatusBar();
450
451 m_text->AppendText(_("\n=== Test 2 begins ===\n"));
452
453 // Tell the server which test we are running
454 unsigned char c = 0xCE;
455 m_sock->Write(&c, 1);
456
457 // Here we use ReadMsg and WriteMsg to send messages with
458 // a header with size information. Also, the reception is
459 // event triggered, so we test input events as well.
460 //
461 // We need to set no flags here (ReadMsg and WriteMsg are
462 // not affected by flags)
463
464 m_sock->SetFlags(wxSOCKET_WAITALL);
465
466 wxString s = wxGetTextFromUser(
467 _("Enter an arbitrary string to send to the server:"),
468 _("Test 2 ..."),
469 _("Yes I like wxWidgets!"));
470
471 msg1 = s.c_str();
472 len = (wxStrlen(msg1) + 1) * sizeof(wxChar);
473 msg2 = new wxChar[wxStrlen(msg1) + 1];
474
475 m_text->AppendText(_("Sending the string with WriteMsg ..."));
476 m_sock->WriteMsg(msg1, len);
477 m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
478 m_text->AppendText(_("Waiting for an event (timeout = 2 sec)\n"));
479
480 // Wait until data available (will also return if the connection is lost)
481 m_sock->WaitForRead(2);
482
483 if (m_sock->IsData())
484 {
485 m_text->AppendText(_("Reading the string back with ReadMsg ..."));
486 m_sock->ReadMsg(msg2, len);
487 m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
488 m_text->AppendText(_("Comparing the two buffers ..."));
489 if (memcmp(msg1, msg2, len) != 0)
490 {
491 m_text->AppendText(_("failed!\n"));
492 m_text->AppendText(_("Test 2 failed !\n"));
493 }
494 else
495 {
496 m_text->AppendText(_("done\n"));
497 m_text->AppendText(_("Test 2 passed !\n"));
498 }
499 }
500 else
501 m_text->AppendText(_("Timeout ! Test 2 failed.\n"));
502
503 m_text->AppendText(_("=== Test 2 ends ===\n"));
504
505 delete[] msg2;
506 m_busy = false;
507 UpdateStatusBar();
508 }
509
510 void MyFrame::OnTest3(wxCommandEvent& WXUNUSED(event))
511 {
512 char *buf1;
513 char *buf2;
514 unsigned char len;
515
516 // Disable socket menu entries (exception: Close Session)
517 m_busy = true;
518 UpdateStatusBar();
519
520 m_text->AppendText(_("\n=== Test 3 begins ===\n"));
521
522 // Tell the server which test we are running
523 unsigned char c = 0xDE;
524 m_sock->Write(&c, 1);
525
526 // This test also is similar to the first one but it sends a
527 // large buffer so that wxSocket is actually forced to split
528 // it into pieces and take care of sending everything before
529 // returning.
530
531 m_sock->SetFlags(wxSOCKET_WAITALL);
532
533 // Note that len is in kbytes here!
534 len = 32;
535 buf1 = new char[len * 1024];
536 buf2 = new char[len * 1024];
537
538 for (int i = 0; i < len * 1024; i ++)
539 buf1[i] = (char)(i % 256);
540
541 m_text->AppendText(_("Sending a large buffer (32K) to the server ..."));
542 m_sock->Write(&len, 1);
543 m_sock->Write(buf1, len * 1024);
544 m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
545
546 m_text->AppendText(_("Receiving the buffer back from server ..."));
547 m_sock->Read(buf2, len * 1024);
548 m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
549
550 m_text->AppendText(_("Comparing the two buffers ..."));
551 if (memcmp(buf1, buf2, len) != 0)
552 {
553 m_text->AppendText(_("failed!\n"));
554 m_text->AppendText(_("Test 3 failed !\n"));
555 }
556 else
557 {
558 m_text->AppendText(_("done\n"));
559 m_text->AppendText(_("Test 3 passed !\n"));
560 }
561 m_text->AppendText(_("=== Test 3 ends ===\n"));
562
563 delete[] buf2;
564 m_busy = false;
565 UpdateStatusBar();
566 }
567
568 void MyFrame::OnCloseConnection(wxCommandEvent& WXUNUSED(event))
569 {
570 m_sock->Close();
571 UpdateStatusBar();
572 }
573
574 void MyFrame::OnDatagram(wxCommandEvent& WXUNUSED(event))
575 {
576 m_text->AppendText(_("\n=== Datagram test begins ===\n"));
577 m_text->AppendText(_("Sorry, not implemented\n"));
578 m_text->AppendText(_("=== Datagram test ends ===\n"));
579 }
580
581 #if wxUSE_URL
582
583 void MyFrame::OnTestURL(wxCommandEvent& WXUNUSED(event))
584 {
585 // Note that we are creating a new socket here, so this
586 // won't mess with the client/server demo.
587
588 // Ask for the URL
589 m_text->AppendText(_("\n=== URL test begins ===\n"));
590 wxString urlname = wxGetTextFromUser(_("Enter an URL to get"),
591 _("URL:"),
592 _T("http://localhost"));
593
594 // Parse the URL
595 wxURL url(urlname);
596 if (url.GetError() != wxURL_NOERR)
597 {
598 m_text->AppendText(_("Error: couldn't parse URL\n"));
599 m_text->AppendText(_("=== URL test ends ===\n"));
600 return;
601 }
602
603 // Try to get the input stream (connects to the given URL)
604 m_text->AppendText(_("Trying to establish connection...\n"));
605 wxYield();
606 wxInputStream *data = url.GetInputStream();
607 if (!data)
608 {
609 m_text->AppendText(_("Error: couldn't read from URL\n"));
610 m_text->AppendText(_("=== URL test ends ===\n"));
611 return;
612 }
613
614 // Print the contents type and file size
615 wxString s;
616 s.Printf(_("Contents type: %s\nFile size: %i\nStarting to download...\n"),
617 url.GetProtocol().GetContentType().c_str(),
618 data->GetSize());
619 m_text->AppendText(s);
620 wxYield();
621
622 // Get the data
623 wxFile fileTest(wxT("test.url"), wxFile::write);
624 wxFileOutputStream sout(fileTest);
625 if (!sout.Ok())
626 {
627 m_text->AppendText(_("Error: couldn't open file for output\n"));
628 m_text->AppendText(_("=== URL test ends ===\n"));
629 return;
630 }
631
632 data->Read(sout);
633 m_text->AppendText(_("Results written to file: test.url\n"));
634 m_text->AppendText(_("Done.\n"));
635 m_text->AppendText(_("=== URL test ends ===\n"));
636
637 delete data;
638 }
639
640 #endif
641
642 void MyFrame::OnSocketEvent(wxSocketEvent& event)
643 {
644 wxString s = _("OnSocketEvent: ");
645
646 switch(event.GetSocketEvent())
647 {
648 case wxSOCKET_INPUT : s.Append(_("wxSOCKET_INPUT\n")); break;
649 case wxSOCKET_LOST : s.Append(_("wxSOCKET_LOST\n")); break;
650 case wxSOCKET_CONNECTION : s.Append(_("wxSOCKET_CONNECTION\n")); break;
651 default : s.Append(_("Unexpected event !\n")); break;
652 }
653
654 m_text->AppendText(s);
655 UpdateStatusBar();
656 }
657
658 // convenience functions
659
660 void MyFrame::UpdateStatusBar()
661 {
662 wxString s;
663
664 if (!m_sock->IsConnected())
665 {
666 s.Printf(_("Not connected"));
667 }
668 else
669 {
670 #if wxUSE_IPV6
671 wxIPV6address addr;
672 #else
673 wxIPV4address addr;
674 #endif
675
676 m_sock->GetPeer(addr);
677 s.Printf(_("%s : %d"), (addr.Hostname()).c_str(), addr.Service());
678 }
679
680 #if wxUSE_STATUSBAR
681 SetStatusText(s, 1);
682 #endif // wxUSE_STATUSBAR
683
684 m_menuSocket->Enable(CLIENT_OPEN, !m_sock->IsConnected() && !m_busy);
685 #if wxUSE_IPV6
686 m_menuSocket->Enable(CLIENT_OPENIPV6, !m_sock->IsConnected() && !m_busy);
687 #endif
688 m_menuSocket->Enable(CLIENT_TEST1, m_sock->IsConnected() && !m_busy);
689 m_menuSocket->Enable(CLIENT_TEST2, m_sock->IsConnected() && !m_busy);
690 m_menuSocket->Enable(CLIENT_TEST3, m_sock->IsConnected() && !m_busy);
691 m_menuSocket->Enable(CLIENT_CLOSE, m_sock->IsConnected());
692 }