1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Socket handler classes
4 // Authors: Guilhem Lavaux, Guillermo Rodriguez Garcia
7 // Copyright: (C) 1999, 1998, 1997, Guilhem Lavaux
9 // License: see wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
15 #pragma implementation "socket.h"
18 // For compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
27 /////////////////////////////////////////////////////////////////////////////
29 /////////////////////////////////////////////////////////////////////////////
31 #include "wx/object.h"
32 #include "wx/string.h"
35 #include "wx/module.h"
42 /////////////////////////////////////////////////////////////////////////////
44 /////////////////////////////////////////////////////////////////////////////
45 #include "wx/sckaddr.h"
46 #include "wx/socket.h"
48 // --------------------------------------------------------------
50 // --------------------------------------------------------------
51 #if !USE_SHARED_LIBRARY
52 IMPLEMENT_CLASS(wxSocketBase
, wxObject
)
53 IMPLEMENT_CLASS(wxSocketServer
, wxSocketBase
)
54 IMPLEMENT_CLASS(wxSocketClient
, wxSocketBase
)
55 IMPLEMENT_DYNAMIC_CLASS(wxSocketEvent
, wxEvent
)
58 class wxSocketState
: public wxObject
62 GSocketEventFlags evt_notify_state
;
63 wxSocketBase::wxSockFlags socket_flags
;
64 wxSocketBase::wxSockCbk c_callback
;
65 char *c_callback_data
;
68 wxSocketState() : wxObject() {}
71 // --------------------------------------------------------------
72 // wxSocketBase ctor and dtor
73 // --------------------------------------------------------------
75 wxSocketBase::wxSocketBase(wxSocketBase::wxSockFlags _flags
,
76 wxSocketBase::wxSockType _type
) :
78 m_socket(NULL
), m_flags(_flags
), m_type(_type
),
80 m_lcount(0), m_timeout(600),
81 m_unread(NULL
), m_unrd_size(0), m_unrd_cur(0),
82 m_cbk(NULL
), m_cdata(NULL
),
83 m_connected(FALSE
), m_establishing(FALSE
),
84 m_notify_state(FALSE
), m_id(-1),
90 wxSocketBase::wxSocketBase() :
92 m_socket(NULL
), m_flags(WAITALL
| SPEED
), m_type(SOCK_UNINIT
),
94 m_lcount(0), m_timeout(600),
95 m_unread(NULL
), m_unrd_size(0), m_unrd_cur(0),
96 m_cbk(NULL
), m_cdata(NULL
),
97 m_connected(FALSE
), m_establishing(FALSE
),
98 m_notify_state(FALSE
), m_id(-1),
104 wxSocketBase::~wxSocketBase()
109 // Shutdown and close the socket
112 // Destroy the GSocket object
114 GSocket_destroy(m_socket
);
117 bool wxSocketBase::Close()
122 GSocket_UnsetCallback(m_socket
, GSOCK_INPUT_FLAG
| GSOCK_OUTPUT_FLAG
|
123 GSOCK_LOST_FLAG
| GSOCK_CONNECTION_FLAG
);
125 // Shutdown the connection
126 GSocket_Shutdown(m_socket
);
128 m_establishing
= FALSE
;
134 // --------------------------------------------------------------
135 // wxSocketBase basic IO operations
136 // --------------------------------------------------------------
138 // GRG: I have made some changes to wxSocket internal event
139 // system; now, all events (INPUT, OUTPUT, CONNECTION, LOST)
140 // are always internally monitored; but users will only be
141 // notified of these events they are interested in. So we
142 // no longer have to change the event mask with SetNotify()
143 // in internal functions like DeferRead, DeferWrite, and
144 // the like. This solves a lot of problems.
146 class _wxSocketInternalTimer
: public wxTimer
150 unsigned long m_new_val
;
154 *m_state
= m_new_val
; // Change the value
158 int wxSocketBase::DeferRead(char *buffer
, wxUint32 nbytes
)
161 _wxSocketInternalTimer timer
;
163 wxASSERT(m_defering
== NO_DEFER
);
165 // Set the defering mode to READ.
166 m_defering
= DEFER_READ
;
168 // Set the current buffer.
169 m_defer_buffer
= buffer
;
170 m_defer_nbytes
= nbytes
;
171 m_defer_timer
= &timer
;
173 timer
.m_state
= (int *)&m_defer_buffer
;
176 timer
.Start(m_timeout
* 1000, FALSE
);
178 // If the socket is readable, call DoDefer for the first time
179 if (GSocket_Select(m_socket
, GSOCK_INPUT_FLAG
))
182 // Wait for buffer completion.
183 while (m_defer_buffer
!= NULL
)
188 // Disable defering mode.
189 m_defering
= NO_DEFER
;
190 m_defer_timer
= NULL
;
192 // Return the number of bytes read from the socket.
193 return nbytes
-m_defer_nbytes
;
196 wxSocketBase
& wxSocketBase::Read(char* buffer
, wxUint32 nbytes
)
200 m_lcount
= GetPushback(buffer
, nbytes
, FALSE
);
207 // If we have got the whole needed buffer, return immediately
213 if (m_flags
& SPEED
& WAITALL
) // SPEED && WAITALL
215 while (ret
> 0 && nbytes
> 0)
217 ret
= GSocket_Read(m_socket
, buffer
, nbytes
);
222 // In case the last call was an error ...
226 else if (m_flags
& SPEED
) // SPEED && !WAITALL
228 ret
= GSocket_Read(m_socket
, buffer
, nbytes
);
235 ret
= DeferRead(buffer
, nbytes
);
244 wxSocketBase
& wxSocketBase::ReadMsg(char* buffer
, wxUint32 nbytes
)
246 unsigned long len
, len2
, sig
;
252 // sig should be an explicit 32-bit unsigned integer; I've seen
253 // compilers in which wxUint32 was actually a 16-bit unsigned integer
255 Read((char *)&msg
, sizeof(msg
));
256 if (m_lcount
!= sizeof(msg
))
259 sig
= msg
.sig
[0] & 0xff;
260 sig
|= (wxUint32
)(msg
.sig
[1] & 0xff) << 8;
261 sig
|= (wxUint32
)(msg
.sig
[2] & 0xff) << 16;
262 sig
|= (wxUint32
)(msg
.sig
[3] & 0xff) << 24;
264 if (sig
!= 0xfeeddead)
266 len
= msg
.len
[0] & 0xff;
267 len
|= (wxUint32
)(msg
.len
[1] & 0xff) << 8;
268 len
|= (wxUint32
)(msg
.len
[2] & 0xff) << 16;
269 len
|= (wxUint32
)(msg
.len
[3] & 0xff) << 24;
271 // len2 is incorrectly computed in the original; this sequence is
280 // the "len &&" in the following statement is necessary so that
281 // we don't attempt to read (and possibly hang the system)
282 // if the message was zero bytes long
283 if (len
&& Read(buffer
, len
).LastCount() != len
)
285 if (len2
&& (Read(NULL
, len2
).LastCount() != len2
))
287 if (Read((char *)&msg
, sizeof(msg
)).LastCount() != sizeof(msg
))
290 sig
= msg
.sig
[0] & 0xff;
291 sig
|= (wxUint32
)(msg
.sig
[1] & 0xff) << 8;
292 sig
|= (wxUint32
)(msg
.sig
[2] & 0xff) << 16;
293 sig
|= (wxUint32
)(msg
.sig
[3] & 0xff) << 24;
296 if (sig
!= 0xdeadfeed)
297 wxLogDebug(_T("Warning: invalid signature returned to ReadMsg\n"));
302 wxSocketBase
& wxSocketBase::Peek(char* buffer
, wxUint32 nbytes
)
304 Read(buffer
, nbytes
);
305 CreatePushbackAfter(buffer
, nbytes
);
310 int wxSocketBase::DeferWrite(const char *buffer
, wxUint32 nbytes
)
313 _wxSocketInternalTimer timer
;
315 wxASSERT(m_defering
== NO_DEFER
);
317 m_defering
= DEFER_WRITE
;
319 // Set the current buffer
320 m_defer_buffer
= (char *)buffer
;
321 m_defer_nbytes
= nbytes
;
322 m_defer_timer
= &timer
;
325 timer
.m_state
= (int *)&m_defer_buffer
;
328 timer
.Start(m_timeout
* 1000, FALSE
);
330 // If the socket is writable, call DoDefer for the first time
331 if (GSocket_Select(m_socket
, GSOCK_OUTPUT_FLAG
))
334 // Wait for buffer completion.
335 while (m_defer_buffer
!= NULL
)
339 m_defer_timer
= NULL
;
342 m_defering
= NO_DEFER
;
344 return nbytes
-m_defer_nbytes
;
347 wxSocketBase
& wxSocketBase::Write(const char *buffer
, wxUint32 nbytes
)
356 if (m_flags
& SPEED
& WAITALL
) // SPEED && WAITALL
358 while (ret
> 0 && nbytes
> 0)
360 ret
= GSocket_Write(m_socket
, buffer
, nbytes
);
365 // In case the last call was an error ...
369 else if (m_flags
& SPEED
) // SPEED && !WAITALL
371 ret
= GSocket_Write(m_socket
, buffer
, nbytes
);
378 ret
= DeferWrite(buffer
, nbytes
);
387 wxSocketBase
& wxSocketBase::WriteMsg(const char *buffer
, wxUint32 nbytes
)
394 // warning about 'cast truncates constant value'
396 #pragma warning(disable: 4310)
397 #endif // __VISUALC__
399 msg
.sig
[0] = (char) 0xad;
400 msg
.sig
[1] = (char) 0xde;
401 msg
.sig
[2] = (char) 0xed;
402 msg
.sig
[3] = (char) 0xfe;
404 msg
.len
[0] = (char) nbytes
& 0xff;
405 msg
.len
[1] = (char) (nbytes
>> 8) & 0xff;
406 msg
.len
[2] = (char) (nbytes
>> 16) & 0xff;
407 msg
.len
[3] = (char) (nbytes
>> 24) & 0xff;
409 if (Write((char *)&msg
, sizeof(msg
)).LastCount() < sizeof(msg
))
411 if (Write(buffer
, nbytes
).LastCount() < nbytes
)
414 msg
.sig
[0] = (char) 0xed;
415 msg
.sig
[1] = (char) 0xfe;
416 msg
.sig
[2] = (char) 0xad;
417 msg
.sig
[3] = (char) 0xde;
418 msg
.len
[0] = msg
.len
[1] = msg
.len
[2] = msg
.len
[3] = (char) 0;
419 Write((char *)&msg
, sizeof(msg
));
424 #pragma warning(default: 4310)
425 #endif // __VISUALC__
428 wxSocketBase
& wxSocketBase::Unread(const char *buffer
, wxUint32 nbytes
)
433 CreatePushbackAfter(buffer
, nbytes
);
439 bool wxSocketBase::IsData() const
444 return (GSocket_Select(m_socket
, GSOCK_INPUT_FLAG
));
447 // GRG: DoDefer() no longer needs to know which event occured,
448 // because this was only used to catch LOST events and set
449 // m_defer_buffer = NULL; this is done in OnRequest() now.
451 void wxSocketBase::DoDefer()
461 ret
= GSocket_Read(m_socket
, m_defer_buffer
, m_defer_nbytes
);
464 ret
= GSocket_Write(m_socket
, m_defer_buffer
, m_defer_nbytes
);
472 m_defer_nbytes
-= ret
;
474 // If we are waiting for all bytes to be acquired, keep the defering
476 if ((m_flags
& WAITALL
) == 0 || m_defer_nbytes
== 0 || ret
< 0)
478 m_defer_buffer
= NULL
;
482 m_defer_buffer
+= ret
;
483 m_defer_timer
->Start(m_timeout
* 1000, FALSE
);
487 void wxSocketBase::Discard()
489 #define MAX_BUFSIZE (10*1024)
491 char *my_data
= new char[MAX_BUFSIZE
];
492 wxUint32 recv_size
= MAX_BUFSIZE
;
495 SetFlags(NOWAIT
| SPEED
);
497 while (recv_size
== MAX_BUFSIZE
)
499 recv_size
= Read(my_data
, MAX_BUFSIZE
).LastCount();
508 // --------------------------------------------------------------
509 // wxSocketBase get local or peer addresses
510 // --------------------------------------------------------------
512 bool wxSocketBase::GetPeer(wxSockAddress
& addr_man
) const
519 peer
= GSocket_GetPeer(m_socket
);
520 addr_man
.SetAddress(peer
);
521 GAddress_destroy(peer
);
526 bool wxSocketBase::GetLocal(wxSockAddress
& addr_man
) const
533 local
= GSocket_GetLocal(m_socket
);
534 addr_man
.SetAddress(local
);
535 GAddress_destroy(local
);
540 // --------------------------------------------------------------
541 // wxSocketBase save and restore socket state
542 // --------------------------------------------------------------
544 void wxSocketBase::SaveState()
546 wxSocketState
*state
;
548 state
= new wxSocketState();
550 state
->notify_state
= m_notify_state
;
551 state
->evt_notify_state
= m_neededreq
;
552 state
->socket_flags
= m_flags
;
553 state
->c_callback
= m_cbk
;
554 state
->c_callback_data
= m_cdata
;
556 m_states
.Append(state
);
559 void wxSocketBase::RestoreState()
562 wxSocketState
*state
;
564 node
= m_states
.Last();
568 state
= (wxSocketState
*)node
->Data();
570 SetFlags(state
->socket_flags
);
571 m_neededreq
= state
->evt_notify_state
;
572 m_cbk
= state
->c_callback
;
573 m_cdata
= state
->c_callback_data
;
574 Notify(state
->notify_state
);
581 // --------------------------------------------------------------
582 // wxSocketBase Wait functions
583 // --------------------------------------------------------------
585 // GRG: I have completely rewritten this family of functions
586 // so that they don't depend on event notifications; instead,
587 // they poll the socket, using GSocket_Select(), to check for
588 // the specified combination of event flags, until an event
589 // occurs or until the timeout ellapses. The polling loop
590 // calls wxYield(), so this won't block the GUI.
592 bool wxSocketBase::_Wait(long seconds
, long milliseconds
, wxSocketEventFlags flags
)
594 GSocketEventFlags result
;
595 _wxSocketInternalTimer timer
;
599 // Check for valid socket
600 if ((!m_connected
&& !m_establishing
) || !m_socket
)
603 // Check for valid timeout value
605 timeout
= seconds
* 1000 + milliseconds
;
607 timeout
= m_timeout
* 1000;
610 timer
.m_state
= &state
;
612 timer
.Start(timeout
, TRUE
);
614 // Active polling (without using events)
615 result
= GSocket_Select(m_socket
, flags
);
617 while ((result
== 0) && (state
== -1))
620 result
= GSocket_Select(m_socket
, flags
);
625 return (result
!= 0);
628 bool wxSocketBase::Wait(long seconds
, long milliseconds
)
630 return _Wait(seconds
, milliseconds
, GSOCK_INPUT_FLAG
|
632 GSOCK_CONNECTION_FLAG
|
636 bool wxSocketBase::WaitForRead(long seconds
, long milliseconds
)
638 return _Wait(seconds
, milliseconds
, GSOCK_INPUT_FLAG
| GSOCK_LOST_FLAG
);
641 bool wxSocketBase::WaitForWrite(long seconds
, long milliseconds
)
643 return _Wait(seconds
, milliseconds
, GSOCK_OUTPUT_FLAG
| GSOCK_LOST_FLAG
);
646 bool wxSocketBase::WaitForLost(long seconds
, long milliseconds
)
648 return _Wait(seconds
, milliseconds
, GSOCK_LOST_FLAG
);
651 // --------------------------------------------------------------
652 // wxSocketBase flags
653 // --------------------------------------------------------------
655 void wxSocketBase::SetFlags(wxSockFlags _flags
)
660 wxSocketBase::wxSockFlags
wxSocketBase::GetFlags() const
665 // --------------------------------------------------------------
666 // wxSocketBase callback management
667 // --------------------------------------------------------------
669 wxSocketBase::wxSockCbk
wxSocketBase::Callback(wxSockCbk cbk_
)
671 wxSockCbk old_cbk
= cbk_
;
677 char *wxSocketBase::CallbackData(char *data
)
679 char *old_data
= m_cdata
;
685 // --------------------------------------------------------------
686 // wxSocketBase automatic notifier
687 // --------------------------------------------------------------
689 static void wx_socket_callback(GSocket
*socket
, GSocketEvent event
, char *cdata
)
691 wxSocketBase
*sckobj
= (wxSocketBase
*)cdata
;
693 sckobj
->OnRequest((wxSocketNotify
)event
);
696 wxSocketEventFlags
wxSocketBase::EventToNotify(wxSocketNotify evt
)
700 case GSOCK_INPUT
: return GSOCK_INPUT_FLAG
;
701 case GSOCK_OUTPUT
: return GSOCK_OUTPUT_FLAG
;
702 case GSOCK_CONNECTION
: return GSOCK_CONNECTION_FLAG
;
703 case GSOCK_LOST
: return GSOCK_LOST_FLAG
;
708 void wxSocketBase::SetNotify(wxSocketEventFlags flags
)
713 void wxSocketBase::Notify(bool notify
)
715 m_notify_state
= notify
;
718 void wxSocketBase::OnRequest(wxSocketNotify req_evt
)
720 wxSocketEvent
event(m_id
);
721 wxSocketEventFlags flag
= EventToNotify(req_evt
);
725 case wxSOCKET_CONNECTION
:
726 m_establishing
= FALSE
;
730 m_defer_buffer
= NULL
;
734 case wxSOCKET_OUTPUT
:
737 // GRG: DoDefer() no longer needs to know which
738 // event occured, because this was only used to
739 // catch LOST events and set m_defer_buffer to
740 // NULL, and this is done in OnRequest() now.
742 // Do not notify to user
748 if (((m_neededreq
& flag
) == flag
) && m_notify_state
)
750 event
.m_socket
= this;
751 event
.m_skevt
= req_evt
;
753 OldOnNotify(req_evt
);
756 m_cbk(*this, req_evt
, m_cdata
);
760 void wxSocketBase::OldOnNotify(wxSocketNotify evt
)
764 // --------------------------------------------------------------
765 // wxSocketBase set event handler
766 // --------------------------------------------------------------
768 void wxSocketBase::SetEventHandler(wxEvtHandler
& h_evt
, int id
)
770 SetNextHandler(&h_evt
);
774 // --------------------------------------------------------------
775 // wxSocketBase pushback library
776 // --------------------------------------------------------------
778 void wxSocketBase::CreatePushbackAfter(const char *buffer
, wxUint32 size
)
782 if (m_unread
!= NULL
)
783 m_unread
= (char *) realloc(m_unread
, m_unrd_size
+size
);
785 m_unread
= (char *) malloc(size
);
787 curr_pos
= m_unread
+ m_unrd_size
;
789 memcpy(curr_pos
, buffer
, size
);
793 void wxSocketBase::CreatePushbackBefore(const char *buffer
, wxUint32 size
)
795 if (m_unread
== NULL
)
796 m_unread
= (char *)malloc(size
);
800 tmp
= (char *)malloc(m_unrd_size
+ size
);
801 memcpy(tmp
+size
, m_unread
, m_unrd_size
);
809 memcpy(m_unread
, buffer
, size
);
812 wxUint32
wxSocketBase::GetPushback(char *buffer
, wxUint32 size
, bool peek
)
817 if (size
> (m_unrd_size
-m_unrd_cur
))
818 size
= m_unrd_size
-m_unrd_cur
;
819 memcpy(buffer
, (m_unread
+m_unrd_cur
), size
);
823 if (m_unrd_size
== m_unrd_cur
) {
834 // --------------------------------------------------------------
836 // --------------------------------------------------------------
838 // --------------------------------------------------------------
839 // wxSocketServer ctor and dtor
840 // --------------------------------------------------------------
842 wxSocketServer::wxSocketServer(wxSockAddress
& addr_man
,
844 wxSocketBase(flags
, SOCK_SERVER
)
847 m_socket
= GSocket_new();
852 // Setup the socket as server
853 GSocket_SetLocal(m_socket
, addr_man
.GetAddress());
854 if (GSocket_SetServer(m_socket
) != GSOCK_NOERROR
)
856 GSocket_destroy(m_socket
);
861 GSocket_SetTimeout(m_socket
, m_timeout
);
862 GSocket_SetCallback(m_socket
, GSOCK_INPUT_FLAG
| GSOCK_OUTPUT_FLAG
|
863 GSOCK_LOST_FLAG
| GSOCK_CONNECTION_FLAG
,
864 wx_socket_callback
, (char *)this);
868 // --------------------------------------------------------------
869 // wxSocketServer Accept
870 // --------------------------------------------------------------
872 bool wxSocketServer::AcceptWith(wxSocketBase
& sock
, bool wait
)
874 GSocket
*child_socket
;
876 // GRG: If wait == FALSE, then the call should be nonblocking.
877 // When we are finished, we put the socket to blocking mode
881 GSocket_SetNonBlocking(m_socket
, TRUE
);
883 child_socket
= GSocket_WaitConnection(m_socket
);
886 GSocket_SetNonBlocking(m_socket
, FALSE
);
888 // GRG: this was not being handled!
889 if (child_socket
== NULL
)
892 sock
.m_type
= SOCK_INTERNAL
;
893 sock
.m_socket
= child_socket
;
894 sock
.m_connected
= TRUE
;
896 GSocket_SetTimeout(sock
.m_socket
, sock
.m_timeout
);
897 GSocket_SetCallback(sock
.m_socket
, GSOCK_INPUT_FLAG
| GSOCK_OUTPUT_FLAG
|
898 GSOCK_LOST_FLAG
| GSOCK_CONNECTION_FLAG
,
899 wx_socket_callback
, (char *)&sock
);
904 wxSocketBase
*wxSocketServer::Accept(bool wait
)
906 wxSocketBase
* sock
= new wxSocketBase();
908 sock
->SetFlags((wxSockFlags
)m_flags
);
910 if (!AcceptWith(*sock
, wait
))
916 bool wxSocketServer::WaitOnAccept(long seconds
, long milliseconds
)
918 return _Wait(seconds
, milliseconds
, GSOCK_CONNECTION_FLAG
| GSOCK_LOST_FLAG
);
921 // --------------------------------------------------------------
923 // --------------------------------------------------------------
925 // --------------------------------------------------------------
926 // wxSocketClient ctor and dtor
927 // --------------------------------------------------------------
929 wxSocketClient::wxSocketClient(wxSockFlags _flags
) :
930 wxSocketBase(_flags
, SOCK_CLIENT
)
934 wxSocketClient::~wxSocketClient()
938 // --------------------------------------------------------------
939 // wxSocketClient Connect functions
940 // --------------------------------------------------------------
941 bool wxSocketClient::Connect(wxSockAddress
& addr_man
, bool wait
)
948 // This should never happen.
950 GSocket_destroy(m_socket
);
952 // Initialize all socket stuff ...
953 m_socket
= GSocket_new();
955 m_establishing
= FALSE
;
960 GSocket_SetTimeout(m_socket
, m_timeout
);
962 // GRG: If wait == FALSE, then the call should be nonblocking.
963 // When we are finished, we put the socket to blocking mode
967 GSocket_SetNonBlocking(m_socket
, TRUE
);
969 GSocket_SetPeer(m_socket
, addr_man
.GetAddress());
970 err
= GSocket_Connect(m_socket
, GSOCK_STREAMED
);
971 GSocket_SetCallback(m_socket
, GSOCK_INPUT_FLAG
| GSOCK_OUTPUT_FLAG
|
972 GSOCK_LOST_FLAG
| GSOCK_CONNECTION_FLAG
,
973 wx_socket_callback
, (char *)this);
976 GSocket_SetNonBlocking(m_socket
, FALSE
);
978 if (err
!= GSOCK_NOERROR
)
980 if (err
== GSOCK_WOULDBLOCK
)
981 m_establishing
= TRUE
;
990 bool wxSocketClient::WaitOnConnect(long seconds
, long milliseconds
)
994 if (m_connected
) // Already connected
997 if (!m_establishing
) // No connection in progress
1000 ret
= _Wait(seconds
, milliseconds
, GSOCK_CONNECTION_FLAG
| GSOCK_LOST_FLAG
);
1002 // GRG: m_connected and m_establishing will be updated in
1003 // OnRequest(), but we do it here anyway because sometimes
1004 // the event might be a bit delayed, and if that happens,
1005 // when WaitOnConnect() returns, m_connected will still be
1006 // FALSE. We have to do it as well in OnRequest because
1007 // maybe WaitOnConnect() is not being used...
1011 m_connected
= GSocket_Select(m_socket
, GSOCK_CONNECTION_FLAG
);
1012 m_establishing
= FALSE
;
1019 void wxSocketClient::OnRequest(wxSocketNotify req_evt
)
1021 wxSocketBase::OnRequest(req_evt
);
1025 // --------------------------------------------------------------
1027 // --------------------------------------------------------------
1029 wxSocketEvent::wxSocketEvent(int id
)
1032 wxEventType type
= (wxEventType
)wxEVT_SOCKET
;
1037 void wxSocketEvent::CopyObject(wxObject
& obj_d
) const
1039 wxSocketEvent
*event
= (wxSocketEvent
*)&obj_d
;
1041 wxEvent::CopyObject(obj_d
);
1043 event
->m_skevt
= m_skevt
;
1044 event
->m_socket
= m_socket
;
1047 // --------------------------------------------------------------------------
1049 // --------------------------------------------------------------------------
1050 class WXDLLEXPORT wxSocketModule
: public wxModule
{
1051 DECLARE_DYNAMIC_CLASS(wxSocketModule
)
1054 return GSocket_Init();
1061 IMPLEMENT_DYNAMIC_CLASS(wxSocketModule
, wxModule
)