X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a324a7bccf4bda8f4f2bf09daee8104cae953cee..6a94433573bab16bcfe85985333323523e4b8517:/include/wx/socket.h?ds=inline diff --git a/include/wx/socket.h b/include/wx/socket.h index b2dcf6056a..496f5a47de 100644 --- a/include/wx/socket.h +++ b/include/wx/socket.h @@ -24,25 +24,27 @@ // wxSocket headers (generic) // --------------------------------------------------------------------------- #ifdef WXPREC - #include "wx/wxprec.h" +# include "wx/wxprec.h" #else - #include "wx/event.h" - #include "wx/string.h" +# include "wx/event.h" +# include "wx/string.h" #endif #include "wx/sckaddr.h" -#include "gsocket.h" +#include "wx/gsocket.h" +class WXDLLEXPORT wxTimer; class WXDLLEXPORT wxSocketEvent; class WXDLLEXPORT wxSocketBase : public wxEvtHandler { DECLARE_CLASS(wxSocketBase) public: - enum wxSockFlags { NONE=0, NOWAIT=1, WAITALL=2, SPEED=4 }; + enum { NONE=0, NOWAIT=1, WAITALL=2, SPEED=4 }; + typedef int wxSockFlags; // Type of request - enum wxSockType { SOCK_CLIENT, SOCK_SERVER, SOCK_INTERNAL, SOCK_UNINIT }; + enum wxSockType { SOCK_CLIENT, SOCK_SERVER, SOCK_INTERNAL, SOCK_UNINIT }; typedef void (*wxSockCbk)(wxSocketBase& sock,GSocketEvent evt,char *cdata); protected: @@ -64,14 +66,16 @@ protected: bool m_notify_state; // Notify state int m_id; // Socket id (for event handler) + // Defering variables enum { DEFER_READ, DEFER_WRITE, NO_DEFER - } m_defering; // Defering state + } m_defering; // Defering state char *m_defer_buffer; // Defering target buffer size_t m_defer_nbytes; // Defering buffer size + wxTimer *m_defer_timer; // Timer for defering mode wxList m_states; // Stack of states - + public: wxSocketBase(); virtual ~wxSocketBase(); @@ -101,7 +105,7 @@ public: inline size_t LastCount() const { return m_lcount; } inline GSocketError LastError() const { return GSocket_GetError(m_socket); } inline wxSockType GetType() const { return m_type; } - + void SetFlags(wxSockFlags _flags); wxSockFlags GetFlags() const; inline void SetTimeout(unsigned long sec) { m_timeout = sec; } @@ -113,7 +117,7 @@ public: bool WaitForRead(long seconds = -1, long microseconds = 0); bool WaitForWrite(long seconds = -1, long microseconds = 0); bool WaitForLost(long seconds = -1, long microseconds = 0); - + // Save the current state of Socket void SaveState(); void RestoreState(); @@ -124,7 +128,7 @@ public: // Setup event handler void SetEventHandler(wxEvtHandler& evt_hdlr, int id = -1); - + // Method called when it happens something on the socket void SetNotify(GSocketEventFlags flags); virtual void OnRequest(GSocketEvent req_evt); @@ -158,13 +162,13 @@ public: #ifdef __SALFORDC__ protected: #endif - + bool _Wait(long seconds, long microseconds, int type); int DeferRead(char *buffer, size_t nbytes); int DeferWrite(const char *buffer, size_t nbytes); void DoDefer(GSocketEvent evt); - + // Pushback library size_t GetPushback(char *buffer, size_t size, bool peek); };