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