wxSOCKET_BLOCK = 4
};
-// Type of request
+// Type of socket
enum wxSockType
{
- SOCK_CLIENT,
- SOCK_SERVER,
- /* SOCK_DGRAM, */
- SOCK_INTERNAL,
- SOCK_UNINIT
+ SOCK_CLIENT,
+ SOCK_SERVER,
+ SOCK_DATAGRAM,
+ SOCK_INTERNAL,
+ SOCK_UNINIT
};
typedef int wxSockFlags;
class WXDLLEXPORT wxTimer;
class WXDLLEXPORT wxSocketEvent;
+
class WXDLLEXPORT wxSocketBase : public wxEvtHandler
{
DECLARE_CLASS(wxSocketBase)
protected:
GSocket *m_socket; // GSocket
+ wxEvtHandler *m_evt_handler; // event handler
int m_id; // Socket id (for event handler)
// Attributes
unsigned long m_timeout; // IO timeout value
wxList m_states; // Stack of states
bool m_interrupt; // Interrupt ongoing wait operations
+ bool m_beingDeleted; // Marked for delayed deletion
// Pushback buffer
char *m_unread; // Pushback buffer
public:
wxSocketBase();
virtual ~wxSocketBase();
- virtual bool Close();
+ virtual bool Destroy();
// Base IO
+ virtual bool Close();
wxSocketBase& Peek(char* buffer, wxUint32 nbytes);
wxSocketBase& Read(char* buffer, wxUint32 nbytes);
wxSocketBase& Write(const char *buffer, wxUint32 nbytes);
bool WaitOnConnect(long seconds = -1, long milliseconds = 0);
};
+////////////////////////////////////////////////////////////////////////
+
+class wxDatagramSocket : public wxSocketBase
+{
+ DECLARE_CLASS(wxDatagramSocket)
+
+public:
+ wxDatagramSocket( wxSockAddress& addr, wxSockFlags flags = wxSOCKET_NONE );
+
+ wxDatagramSocket& RecvFrom( wxSockAddress& addr,
+ char* buf,
+ wxUint32 nBytes );
+ wxDatagramSocket& SendTo( wxSockAddress& addr,
+ const char* buf,
+ wxUint32 nBytes );
+};
+
+////////////////////////////////////////////////////////////////////////
+
class WXDLLEXPORT wxSocketEvent : public wxEvent {
DECLARE_DYNAMIC_CLASS(wxSocketEvent)
public: