class wxSocketState : public wxObject {
public:
- bool notify_state;
+ bool notify_state;
GSocketEventFlags evt_notify_state;
wxSocketBase::wxSockFlags socket_flags;
wxSocketBase::wxSockCbk c_callback;
wxEvtHandler(),
m_socket(NULL), m_flags(_flags), m_type(_type),
m_neededreq(GSOCK_INPUT_FLAG | GSOCK_LOST_FLAG),
- m_lcount(0), m_timeout(3600),
+ m_lcount(0), m_timeout(600),
m_unread(NULL), m_unrd_size(0), m_unrd_cur(0),
m_cbk(NULL), m_cdata(NULL),
m_connected(FALSE), m_notify_state(FALSE), m_id(-1),
wxSocketBase::wxSocketBase() :
wxEvtHandler(),
- m_socket(NULL), m_flags((wxSockFlags)SPEED | WAITALL), m_type(SOCK_UNINIT),
+ m_socket(NULL), m_flags(SPEED | WAITALL), m_type(SOCK_UNINIT),
m_neededreq(GSOCK_INPUT_FLAG | GSOCK_LOST_FLAG),
- m_lcount(0), m_timeout(3600),
+ m_lcount(0), m_timeout(600),
m_unread(NULL), m_unrd_size(0), m_unrd_cur(0),
m_cbk(NULL), m_cdata(NULL),
m_connected(FALSE), m_notify_state(FALSE), m_id(-1),
bool wxSocketBase::Close()
{
- if (m_socket)
+ if (m_socket)
{
if (m_notify_state == TRUE)
Notify(FALSE);
old_event_flags = NeededReq();
old_notify_state = m_notify_state;
-
+
SetNotify(GSOCK_INPUT_FLAG | GSOCK_LOST_FLAG);
Notify(TRUE);
size_t recv_size = MAX_BUFSIZE;
SaveState();
- SetFlags((wxSockFlags)(NOWAIT | SPEED));
+ SetFlags(NOWAIT | SPEED);
- while (recv_size == MAX_BUFSIZE)
+ while (recv_size == MAX_BUFSIZE)
{
recv_size = Read(my_data, MAX_BUFSIZE).LastCount();
}
GSocketEventFlags wxSocketBase::EventToNotify(GSocketEvent evt)
{
- switch (evt)
+ switch (evt)
{
case GSOCK_INPUT:
return GSOCK_INPUT_FLAG;
return GSOCK_OUTPUT_FLAG;
case GSOCK_CONNECTION:
return GSOCK_CONNECTION_FLAG;
- case GSOCK_LOST_FLAG:
+ case GSOCK_LOST:
return GSOCK_LOST_FLAG;
default:
return 0;
m_unread = tmp;
}
-
+
m_unrd_size += size;
memcpy(m_unread, buffer, size);
// Update the flags of m_socket.
SetFlags(m_flags);
GSocket_SetPeer(m_socket, addr_man.GetAddress());
- if (GSocket_Connect(m_socket, GSOCK_STREAMED) != GSOCK_NOERROR) {
+ if (GSocket_Connect(m_socket, GSOCK_STREAMED) != GSOCK_NOERROR)
return FALSE;
- }
// Enables bg events.
// ------------------
void wxSocketClient::OnRequest(GSocketEvent evt)
{
- if (evt == GSOCK_CONNECTION)
+ if (evt == GSOCK_CONNECTION)
{
- if (m_connected)
+ if (m_connected)
{
m_neededreq &= ~GSOCK_CONNECTION_FLAG;
return;
event->m_socket = m_socket;
}
+// --------------------------------------------------------------------------
+// wxSocketModule
+// --------------------------------------------------------------------------
+class WXDLLEXPORT wxSocketModule: public wxModule {
+ DECLARE_DYNAMIC_CLASS(wxSocketModule)
+ public:
+ bool OnInit() {
+ return GSocket_Init();
+ }
+ void OnExit() {
+ GSocket_Cleanup();
+ }
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxSocketModule, wxModule)
+
#endif
// wxUSE_SOCKETS