1998-09-06 18:28:00 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: socket.h
|
|
|
|
// Purpose: Socket handling classes
|
1999-09-11 20:29:50 +00:00
|
|
|
// Authors: Guilhem Lavaux, Guillermo Rodriguez Garcia
|
1998-09-06 18:28:00 +00:00
|
|
|
// Modified by:
|
|
|
|
// Created: April 1997
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Guilhem Lavaux
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1998-09-10 11:41:14 +00:00
|
|
|
|
1998-09-06 18:28:00 +00:00
|
|
|
#ifndef _WX_NETWORK_SOCKET_H
|
|
|
|
#define _WX_NETWORK_SOCKET_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
2000-03-10 05:31:53 +00:00
|
|
|
#pragma interface "socket.h"
|
1998-09-06 18:28:00 +00:00
|
|
|
#endif
|
|
|
|
|
1999-06-15 20:21:59 +00:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_SOCKETS
|
|
|
|
|
1998-09-06 18:28:00 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
2000-03-07 16:11:58 +00:00
|
|
|
// wxSocket headers
|
1998-09-06 18:28:00 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
1999-09-30 23:53:10 +00:00
|
|
|
|
1998-09-06 18:28:00 +00:00
|
|
|
#ifdef WXPREC
|
2000-03-10 05:31:53 +00:00
|
|
|
#include "wx/wxprec.h"
|
1998-09-06 18:28:00 +00:00
|
|
|
#else
|
2000-03-10 05:31:53 +00:00
|
|
|
#include "wx/event.h"
|
|
|
|
#include "wx/string.h"
|
1998-09-06 18:28:00 +00:00
|
|
|
#endif
|
1999-06-26 11:56:44 +00:00
|
|
|
|
1999-08-20 22:52:21 +00:00
|
|
|
#include "wx/sckaddr.h"
|
1999-07-29 05:27:19 +00:00
|
|
|
#include "wx/gsocket.h"
|
1998-09-06 18:28:00 +00:00
|
|
|
|
1999-09-05 05:51:05 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2000-03-07 16:11:58 +00:00
|
|
|
// Types and constants
|
1999-09-05 05:51:05 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
|
1999-10-21 19:44:11 +00:00
|
|
|
enum wxSocketNotify
|
|
|
|
{
|
1999-09-05 05:51:05 +00:00
|
|
|
wxSOCKET_INPUT = GSOCK_INPUT,
|
|
|
|
wxSOCKET_OUTPUT = GSOCK_OUTPUT,
|
|
|
|
wxSOCKET_CONNECTION = GSOCK_CONNECTION,
|
|
|
|
wxSOCKET_LOST = GSOCK_LOST
|
1999-10-21 19:44:11 +00:00
|
|
|
};
|
1999-09-05 05:51:05 +00:00
|
|
|
|
1999-10-21 19:44:11 +00:00
|
|
|
enum
|
|
|
|
{
|
1999-09-05 05:51:05 +00:00
|
|
|
wxSOCKET_INPUT_FLAG = GSOCK_INPUT_FLAG,
|
|
|
|
wxSOCKET_OUTPUT_FLAG = GSOCK_OUTPUT_FLAG,
|
|
|
|
wxSOCKET_CONNECTION_FLAG = GSOCK_CONNECTION_FLAG,
|
1999-09-09 21:22:51 +00:00
|
|
|
wxSOCKET_LOST_FLAG = GSOCK_LOST_FLAG
|
1999-09-05 05:51:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef GSocketEventFlags wxSocketEventFlags;
|
|
|
|
|
1999-10-21 19:44:11 +00:00
|
|
|
enum wxSocketError
|
|
|
|
{
|
2000-03-16 21:57:20 +00:00
|
|
|
// from GSocket
|
1999-09-05 05:51:05 +00:00
|
|
|
wxSOCKET_NOERROR = GSOCK_NOERROR,
|
2000-03-16 21:57:20 +00:00
|
|
|
wxSOCKET_INVOP = GSOCK_INVOP,
|
1999-09-05 05:51:05 +00:00
|
|
|
wxSOCKET_IOERR = GSOCK_IOERR,
|
|
|
|
wxSOCKET_INVADDR = GSOCK_INVADDR,
|
|
|
|
wxSOCKET_INVSOCK = GSOCK_INVSOCK,
|
|
|
|
wxSOCKET_NOHOST = GSOCK_NOHOST,
|
|
|
|
wxSOCKET_INVPORT = GSOCK_INVPORT,
|
|
|
|
wxSOCKET_WOULDBLOCK = GSOCK_WOULDBLOCK,
|
1999-09-05 10:23:22 +00:00
|
|
|
wxSOCKET_TIMEDOUT = GSOCK_TIMEDOUT,
|
2000-03-16 21:57:20 +00:00
|
|
|
wxSOCKET_MEMERR = GSOCK_MEMERR,
|
|
|
|
|
|
|
|
// wxSocket-specific (not yet implemented)
|
|
|
|
wxSOCKET_DUMMY
|
1999-10-21 19:44:11 +00:00
|
|
|
};
|
1999-09-05 05:51:05 +00:00
|
|
|
|
1999-10-21 19:44:11 +00:00
|
|
|
enum
|
|
|
|
{
|
1999-09-30 23:53:10 +00:00
|
|
|
wxSOCKET_NONE = 0,
|
|
|
|
wxSOCKET_NOWAIT = 1,
|
|
|
|
wxSOCKET_WAITALL = 2,
|
|
|
|
wxSOCKET_BLOCK = 4
|
|
|
|
};
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
enum wxSocketType
|
1999-10-21 19:44:11 +00:00
|
|
|
{
|
2000-03-07 16:11:58 +00:00
|
|
|
wxSOCKET_UNINIT,
|
|
|
|
wxSOCKET_CLIENT,
|
|
|
|
wxSOCKET_SERVER,
|
|
|
|
wxSOCKET_BASE,
|
|
|
|
wxSOCKET_DATAGRAM
|
1999-10-21 19:44:11 +00:00
|
|
|
};
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
typedef int wxSocketFlags;
|
1999-09-30 23:53:10 +00:00
|
|
|
|
1999-09-05 05:51:05 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
#if WXWIN_COMPATIBILITY
|
2000-03-10 05:31:53 +00:00
|
|
|
typedef wxSocketType wxSockType;
|
|
|
|
typedef wxSocketFlags wxSockFlags;
|
2000-03-07 16:11:58 +00:00
|
|
|
#endif // WXWIN_COMPATIBILITY
|
2000-01-14 10:04:12 +00:00
|
|
|
|
2000-03-10 05:31:53 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// wxSocketBase
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxSocketBase : public wxObject
|
1998-09-06 18:28:00 +00:00
|
|
|
{
|
|
|
|
DECLARE_CLASS(wxSocketBase)
|
2000-03-07 16:11:58 +00:00
|
|
|
|
1998-09-06 18:28:00 +00:00
|
|
|
public:
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
#if WXWIN_COMPATIBILITY
|
1999-10-21 19:44:11 +00:00
|
|
|
enum
|
|
|
|
{
|
1999-09-30 23:53:10 +00:00
|
|
|
NONE = wxSOCKET_NONE,
|
|
|
|
NOWAIT = wxSOCKET_NOWAIT,
|
|
|
|
WAITALL = wxSOCKET_WAITALL,
|
|
|
|
SPEED = wxSOCKET_BLOCK
|
|
|
|
};
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SOCK_UNINIT = wxSOCKET_UNINIT,
|
|
|
|
SOCK_CLIENT = wxSOCKET_CLIENT,
|
|
|
|
SOCK_SERVER = wxSOCKET_SERVER,
|
|
|
|
SOCK_INTERNAL = wxSOCKET_BASE,
|
|
|
|
SOCK_DATAGRAM = wxSOCKET_DATAGRAM
|
|
|
|
};
|
1998-09-06 18:28:00 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
typedef void (*wxSockCbk)(wxSocketBase& sock, wxSocketNotify evt, char *cdata);
|
2000-03-10 05:31:53 +00:00
|
|
|
#endif // WXWIN_COMPATIBILITY
|
2000-01-10 03:54:37 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
public:
|
2000-01-10 03:54:37 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
// Public interface
|
|
|
|
// ----------------
|
1999-07-29 05:27:19 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
// ctors and dtors
|
1998-09-06 18:28:00 +00:00
|
|
|
wxSocketBase();
|
2000-03-07 16:11:58 +00:00
|
|
|
wxSocketBase(wxSocketFlags flags, wxSocketType type);
|
1998-09-06 18:28:00 +00:00
|
|
|
virtual ~wxSocketBase();
|
2000-03-07 16:11:58 +00:00
|
|
|
void Init();
|
|
|
|
bool Destroy();
|
1998-09-06 18:28:00 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
// state
|
1999-07-22 17:51:54 +00:00
|
|
|
inline bool Ok() const { return (m_socket != NULL); };
|
1999-09-15 00:04:44 +00:00
|
|
|
inline bool Error() const { return m_error; };
|
1998-09-06 18:28:00 +00:00
|
|
|
inline bool IsConnected() const { return m_connected; };
|
1999-09-30 23:53:10 +00:00
|
|
|
inline bool IsData() { return WaitForRead(0, 0); };
|
2000-03-07 16:11:58 +00:00
|
|
|
inline bool IsDisconnected() const { return !IsConnected(); };
|
1999-09-05 10:23:22 +00:00
|
|
|
inline wxUint32 LastCount() const { return m_lcount; }
|
1999-09-05 05:51:05 +00:00
|
|
|
inline wxSocketError LastError() const { return (wxSocketError)GSocket_GetError(m_socket); }
|
2000-03-07 16:11:58 +00:00
|
|
|
void SaveState();
|
|
|
|
void RestoreState();
|
1999-07-29 05:27:19 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
// addresses
|
1999-09-15 00:04:44 +00:00
|
|
|
virtual bool GetLocal(wxSockAddress& addr_man) const;
|
2000-03-07 16:11:58 +00:00
|
|
|
virtual bool GetPeer(wxSockAddress& addr_man) const;
|
1999-09-15 00:04:44 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
// base IO
|
|
|
|
virtual bool Close();
|
|
|
|
wxSocketBase& Discard();
|
2000-03-08 08:28:20 +00:00
|
|
|
wxSocketBase& Peek(void* buffer, wxUint32 nbytes);
|
|
|
|
wxSocketBase& Read(void* buffer, wxUint32 nbytes);
|
|
|
|
wxSocketBase& ReadMsg(void *buffer, wxUint32 nbytes);
|
|
|
|
wxSocketBase& Unread(const void *buffer, wxUint32 nbytes);
|
|
|
|
wxSocketBase& Write(const void *buffer, wxUint32 nbytes);
|
|
|
|
wxSocketBase& WriteMsg(const void *buffer, wxUint32 nbytes);
|
2000-03-07 16:11:58 +00:00
|
|
|
|
2000-03-10 05:31:53 +00:00
|
|
|
void InterruptWait() { m_interrupt = TRUE; };
|
1999-09-05 10:23:22 +00:00
|
|
|
bool Wait(long seconds = -1, long milliseconds = 0);
|
|
|
|
bool WaitForRead(long seconds = -1, long milliseconds = 0);
|
|
|
|
bool WaitForWrite(long seconds = -1, long milliseconds = 0);
|
|
|
|
bool WaitForLost(long seconds = -1, long milliseconds = 0);
|
1999-07-29 05:27:19 +00:00
|
|
|
|
2000-03-08 08:28:20 +00:00
|
|
|
inline wxSocketFlags GetFlags() const { return m_flags; }
|
2000-03-07 16:11:58 +00:00
|
|
|
void SetFlags(wxSocketFlags flags);
|
|
|
|
void SetTimeout(long seconds);
|
1999-07-29 05:27:19 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
// event handling
|
2000-03-08 08:28:20 +00:00
|
|
|
void *GetClientData() const { return m_clientData; }
|
|
|
|
void SetClientData(void *data) { m_clientData = data; }
|
2000-03-07 16:11:58 +00:00
|
|
|
void SetEventHandler(wxEvtHandler& handler, int id = -1);
|
1999-09-05 05:51:05 +00:00
|
|
|
void SetNotify(wxSocketEventFlags flags);
|
1999-09-15 00:04:44 +00:00
|
|
|
void Notify(bool notify);
|
|
|
|
|
2002-02-24 13:51:43 +00:00
|
|
|
// initialize/shutdown the sockets (usually called automatically)
|
|
|
|
static bool IsInitialized();
|
|
|
|
static bool Initialize();
|
|
|
|
static void Shutdown();
|
|
|
|
|
2000-03-10 05:31:53 +00:00
|
|
|
// callbacks are deprecated, use events instead
|
|
|
|
#if WXWIN_COMPATIBILITY
|
1999-09-15 00:04:44 +00:00
|
|
|
wxSockCbk Callback(wxSockCbk cbk_);
|
|
|
|
char *CallbackData(char *data);
|
2000-03-10 05:31:53 +00:00
|
|
|
#endif // WXWIN_COMPATIBILITY
|
1998-09-06 18:28:00 +00:00
|
|
|
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
// Implementation from now on
|
|
|
|
// --------------------------
|
1998-09-06 18:28:00 +00:00
|
|
|
|
2000-03-16 21:57:20 +00:00
|
|
|
// do not use, should be private (called from GSocket)
|
2000-03-10 05:31:53 +00:00
|
|
|
void OnRequest(wxSocketNotify notify);
|
1999-01-19 11:00:22 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
// do not use, not documented nor supported
|
2000-03-10 05:31:53 +00:00
|
|
|
inline bool IsNoWait() const { return ((m_flags & wxSOCKET_NOWAIT) != 0); }
|
2000-03-07 16:11:58 +00:00
|
|
|
inline wxSocketType GetType() const { return m_type; }
|
1999-01-19 11:00:22 +00:00
|
|
|
|
2000-03-07 17:16:54 +00:00
|
|
|
private:
|
|
|
|
friend class wxSocketClient;
|
|
|
|
friend class wxSocketServer;
|
|
|
|
friend class wxDatagramSocket;
|
1999-07-29 05:27:19 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
// low level IO
|
2000-03-08 08:28:20 +00:00
|
|
|
wxUint32 _Read(void* buffer, wxUint32 nbytes);
|
|
|
|
wxUint32 _Write(const void *buffer, wxUint32 nbytes);
|
2000-03-16 21:57:20 +00:00
|
|
|
bool _Wait(long seconds, long milliseconds, wxSocketEventFlags flags);
|
1998-09-06 18:28:00 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
// pushback buffer
|
2000-03-16 21:57:20 +00:00
|
|
|
void Pushback(const void *buffer, wxUint32 size);
|
2000-03-08 08:28:20 +00:00
|
|
|
wxUint32 GetPushback(void *buffer, wxUint32 size, bool peek);
|
2000-03-07 16:11:58 +00:00
|
|
|
|
2000-03-07 17:16:54 +00:00
|
|
|
private:
|
2000-03-16 21:57:20 +00:00
|
|
|
// socket
|
2000-03-07 16:11:58 +00:00
|
|
|
GSocket *m_socket; // GSocket
|
|
|
|
wxSocketType m_type; // wxSocket type
|
|
|
|
|
|
|
|
// state
|
|
|
|
wxSocketFlags m_flags; // wxSocket flags
|
|
|
|
bool m_connected; // connected?
|
|
|
|
bool m_establishing; // establishing connection?
|
|
|
|
bool m_reading; // busy reading?
|
|
|
|
bool m_writing; // busy writing?
|
|
|
|
bool m_error; // did last IO call fail?
|
2000-03-16 21:57:20 +00:00
|
|
|
wxSocketError m_lasterror; // last error (not cleared on success)
|
2000-03-07 16:11:58 +00:00
|
|
|
wxUint32 m_lcount; // last IO transaction size
|
|
|
|
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
|
2000-03-08 08:28:20 +00:00
|
|
|
void *m_unread; // pushback buffer
|
2000-03-07 16:11:58 +00:00
|
|
|
wxUint32 m_unrd_size; // pushback buffer size
|
|
|
|
wxUint32 m_unrd_cur; // pushback pointer (index into buffer)
|
|
|
|
|
|
|
|
// events
|
|
|
|
int m_id; // socket id
|
2000-03-08 08:28:20 +00:00
|
|
|
wxEvtHandler *m_handler; // event handler
|
|
|
|
void *m_clientData; // client data for events
|
2000-03-10 05:31:53 +00:00
|
|
|
bool m_notify; // notify events to users?
|
|
|
|
wxSocketEventFlags m_eventmask; // which events to notify?
|
2000-03-08 08:28:20 +00:00
|
|
|
|
2002-02-24 13:51:43 +00:00
|
|
|
// the initialization count, GSocket is initialized if > 0
|
|
|
|
static size_t m_countInit;
|
|
|
|
|
2000-03-10 05:31:53 +00:00
|
|
|
// callbacks are deprecated, use events instead
|
|
|
|
#if WXWIN_COMPATIBILITY
|
2000-03-07 16:11:58 +00:00
|
|
|
wxSockCbk m_cbk; // callback
|
|
|
|
char *m_cdata; // callback data
|
2000-03-10 05:31:53 +00:00
|
|
|
#endif // WXWIN_COMPATIBILITY
|
1998-09-06 18:28:00 +00:00
|
|
|
};
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// wxSocketServer
|
|
|
|
// --------------------------------------------------------------------------
|
1998-09-06 18:28:00 +00:00
|
|
|
|
|
|
|
class WXDLLEXPORT wxSocketServer : public wxSocketBase
|
|
|
|
{
|
|
|
|
DECLARE_CLASS(wxSocketServer)
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
public:
|
|
|
|
wxSocketServer(wxSockAddress& addr, wxSocketFlags flags = wxSOCKET_NONE);
|
1998-09-06 18:28:00 +00:00
|
|
|
|
1999-09-09 22:08:31 +00:00
|
|
|
wxSocketBase* Accept(bool wait = TRUE);
|
2000-03-07 16:11:58 +00:00
|
|
|
bool AcceptWith(wxSocketBase& socket, bool wait = TRUE);
|
1999-09-09 22:08:31 +00:00
|
|
|
|
1999-09-15 00:04:44 +00:00
|
|
|
bool WaitForAccept(long seconds = -1, long milliseconds = 0);
|
1998-09-06 18:28:00 +00:00
|
|
|
};
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// wxSocketClient
|
|
|
|
// --------------------------------------------------------------------------
|
1998-09-06 18:28:00 +00:00
|
|
|
|
|
|
|
class WXDLLEXPORT wxSocketClient : public wxSocketBase
|
|
|
|
{
|
|
|
|
DECLARE_CLASS(wxSocketClient)
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
public:
|
|
|
|
wxSocketClient(wxSocketFlags flags = wxSOCKET_NONE);
|
1998-09-06 18:28:00 +00:00
|
|
|
virtual ~wxSocketClient();
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
virtual bool Connect(wxSockAddress& addr, bool wait = TRUE);
|
1998-09-06 18:28:00 +00:00
|
|
|
|
1999-09-05 10:23:22 +00:00
|
|
|
bool WaitOnConnect(long seconds = -1, long milliseconds = 0);
|
1998-09-06 18:28:00 +00:00
|
|
|
};
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// wxDatagramSocket
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// WARNING: still in alpha stage
|
2000-01-14 10:04:12 +00:00
|
|
|
|
|
|
|
class wxDatagramSocket : public wxSocketBase
|
|
|
|
{
|
|
|
|
DECLARE_CLASS(wxDatagramSocket)
|
|
|
|
|
|
|
|
public:
|
2000-03-07 16:11:58 +00:00
|
|
|
wxDatagramSocket(wxSockAddress& addr, wxSocketFlags flags = wxSOCKET_NONE);
|
2000-01-14 10:04:12 +00:00
|
|
|
|
|
|
|
wxDatagramSocket& RecvFrom( wxSockAddress& addr,
|
2000-03-08 08:28:20 +00:00
|
|
|
void* buf,
|
2000-01-14 10:04:12 +00:00
|
|
|
wxUint32 nBytes );
|
|
|
|
wxDatagramSocket& SendTo( wxSockAddress& addr,
|
2000-03-08 08:28:20 +00:00
|
|
|
const void* buf,
|
2000-01-14 10:04:12 +00:00
|
|
|
wxUint32 nBytes );
|
2000-03-16 21:57:20 +00:00
|
|
|
|
|
|
|
/* TODO:
|
|
|
|
bool Connect(wxSockAddress& addr);
|
|
|
|
*/
|
2000-01-14 10:04:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// wxSocketEvent
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxSocketEvent : public wxEvent
|
|
|
|
{
|
1998-09-06 18:28:00 +00:00
|
|
|
public:
|
2001-11-21 17:25:08 +00:00
|
|
|
wxSocketEvent(int id = 0)
|
|
|
|
: wxEvent(id, wxEVT_SOCKET)
|
|
|
|
{
|
|
|
|
}
|
1998-09-06 18:28:00 +00:00
|
|
|
|
2000-03-08 08:28:20 +00:00
|
|
|
wxSocketNotify GetSocketEvent() const { return m_event; }
|
|
|
|
wxSocketBase *GetSocket() const { return (wxSocketBase *) GetEventObject(); }
|
|
|
|
void *GetClientData() const { return m_clientData; }
|
|
|
|
|
|
|
|
// backwards compatibility
|
2000-03-16 21:57:20 +00:00
|
|
|
#if WXWIN_COMPATIBILITY_2
|
2000-03-08 08:28:20 +00:00
|
|
|
wxSocketNotify SocketEvent() const { return m_event; }
|
|
|
|
wxSocketBase *Socket() const { return (wxSocketBase *) GetEventObject(); }
|
2000-03-16 21:57:20 +00:00
|
|
|
#endif // WXWIN_COMPATIBILITY_2
|
1999-04-26 18:16:56 +00:00
|
|
|
|
2001-11-21 17:25:08 +00:00
|
|
|
virtual wxEvent *Clone() const { return new wxSocketEvent(*this); }
|
1999-05-07 18:34:32 +00:00
|
|
|
|
1998-09-06 18:28:00 +00:00
|
|
|
public:
|
2000-03-07 16:11:58 +00:00
|
|
|
wxSocketNotify m_event;
|
2000-03-08 08:28:20 +00:00
|
|
|
void *m_clientData;
|
2001-11-21 17:25:08 +00:00
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxSocketEvent)
|
1998-09-06 18:28:00 +00:00
|
|
|
};
|
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
|
1998-09-06 18:28:00 +00:00
|
|
|
typedef void (wxEvtHandler::*wxSocketEventFunction)(wxSocketEvent&);
|
|
|
|
|
2001-01-31 17:16:40 +00:00
|
|
|
#define EVT_SOCKET(id, func) \
|
|
|
|
DECLARE_EVENT_TABLE_ENTRY( wxEVT_SOCKET, id, -1, \
|
|
|
|
(wxObjectEventFunction) \
|
|
|
|
(wxEventFunction) \
|
|
|
|
(wxSocketEventFunction) & func, \
|
|
|
|
(wxObject *) NULL ),
|
1998-09-06 18:28:00 +00:00
|
|
|
|
2000-03-07 16:11:58 +00:00
|
|
|
|
1998-09-06 18:28:00 +00:00
|
|
|
#endif
|
1999-06-15 20:21:59 +00:00
|
|
|
// wxUSE_SOCKETS
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_NETWORK_SOCKET_H
|