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