continuation of GSocket/wxSocket merge: always create GSocket associated to a wxSocket instead of (always) doing it using a separate call later; remove support for user callbacks which wasn't implemented in Windows version and deprecated since 10 years or so
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56934 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "wx/dlimpexp.h" /* for WXDLLIMPEXP_NET */
|
||||
|
||||
class WXDLLIMPEXP_FWD_NET wxSocketBase;
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/*
|
||||
@@ -163,13 +165,17 @@ private:
|
||||
class GSocketBase
|
||||
{
|
||||
public:
|
||||
// static factory function
|
||||
static GSocket *Create();
|
||||
// static factory function: creates the low-level socket associated with
|
||||
// the given wxSocket (and inherits its attributes such as timeout)
|
||||
static GSocket *Create(wxSocketBase& wxsocket);
|
||||
|
||||
void SetTimeout(unsigned long millisec);
|
||||
virtual ~GSocketBase();
|
||||
|
||||
GSocketEventFlags Select(GSocketEventFlags flags);
|
||||
|
||||
virtual GSocket *WaitConnection(wxSocketBase& wxsocket) = 0;
|
||||
|
||||
virtual void Close() = 0;
|
||||
virtual void Shutdown();
|
||||
|
||||
@@ -200,11 +206,19 @@ public:
|
||||
#endif
|
||||
|
||||
GSocketEventFlags m_detected;
|
||||
GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
|
||||
char *m_data[GSOCK_MAX_EVENT];
|
||||
|
||||
protected:
|
||||
GSocketBase();
|
||||
GSocketBase(wxSocketBase& wxsocket);
|
||||
|
||||
// notify m_wxsocket
|
||||
void NotifyOnStateChange(GSocketEvent event);
|
||||
|
||||
private:
|
||||
// set in ctor and never changed except that it's reset to NULL when the
|
||||
// socket is shut down
|
||||
wxSocketBase *m_wxsocket;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(GSocketBase)
|
||||
};
|
||||
|
||||
#if defined(__WINDOWS__)
|
||||
|
@@ -27,16 +27,23 @@
|
||||
class GSocket : public GSocketBase
|
||||
{
|
||||
public:
|
||||
GSocket() : GSocketBase() { m_msgnumber = 0; }
|
||||
GSocket::GSocket(wxSocketBase& wxsocket)
|
||||
: GSocketBase(wxsocket)
|
||||
{
|
||||
m_msgnumber = 0;
|
||||
}
|
||||
|
||||
virtual void Close();
|
||||
|
||||
virtual GSocket *WaitConnection(wxSocketBase& wxsocket);
|
||||
|
||||
virtual void Close();
|
||||
|
||||
GSocketError SetLocal(GAddress *address);
|
||||
GSocketError SetPeer(GAddress *address);
|
||||
GAddress *GetLocal();
|
||||
GAddress *GetPeer();
|
||||
GSocketError SetServer();
|
||||
GSocket *WaitConnection();
|
||||
|
||||
// not used under MSW
|
||||
void Notify(bool) { }
|
||||
bool SetReusable();
|
||||
@@ -47,11 +54,7 @@ public:
|
||||
int Read(char *buffer, int size);
|
||||
int Write(const char *buffer, int size);
|
||||
void SetNonBlocking(bool non_block);
|
||||
void SetTimeout(unsigned long millis);
|
||||
GSocketError WXDLLIMPEXP_NET GetError();
|
||||
void SetCallback(GSocketEventFlags flags,
|
||||
GSocketCallback callback, char *cdata);
|
||||
void UnsetCallback(GSocketEventFlags flags);
|
||||
GSocketError GetSockOpt(int level, int optname,
|
||||
void *optval, int *optlen);
|
||||
GSocketError SetSockOpt(int level, int optname,
|
||||
|
@@ -16,16 +16,18 @@ class wxGSocketIOHandler;
|
||||
class GSocket : public GSocketBase
|
||||
{
|
||||
public:
|
||||
GSocket();
|
||||
~GSocket();
|
||||
GSocket(wxSocketBase& wxsocket);
|
||||
virtual ~GSocket();
|
||||
|
||||
virtual void Close();
|
||||
virtual void Shutdown();
|
||||
virtual GSocket *WaitConnection(wxSocketBase& wxsocket);
|
||||
|
||||
GSocketError SetLocal(GAddress *address);
|
||||
GSocketError SetPeer(GAddress *address);
|
||||
GAddress *GetLocal();
|
||||
GAddress *GetPeer();
|
||||
GSocketError SetServer();
|
||||
GSocket *WaitConnection();
|
||||
bool SetReusable();
|
||||
bool SetBroadcast();
|
||||
bool DontDoBind();
|
||||
@@ -34,11 +36,7 @@ public:
|
||||
int Read(char *buffer, int size);
|
||||
int Write(const char *buffer, int size);
|
||||
void SetNonBlocking(bool non_block);
|
||||
void SetTimeout(unsigned long millisec);
|
||||
GSocketError WXDLLIMPEXP_NET GetError();
|
||||
void SetCallback(GSocketEventFlags flags,
|
||||
GSocketCallback callback, char *cdata);
|
||||
void UnsetCallback(GSocketEventFlags flags);
|
||||
GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen);
|
||||
GSocketError SetSockOpt(int level, int optname,
|
||||
const void *optval, int optlen);
|
||||
@@ -74,6 +72,11 @@ public:
|
||||
|
||||
// pointer for storing extra (usually GUI-specific) data
|
||||
void *m_gui_dependent;
|
||||
|
||||
private:
|
||||
// notify the associated wxSocket about a change in socket state and shut
|
||||
// down the socket if the event is GSOCK_LOST
|
||||
void OnStateChange(GSocketEvent event);
|
||||
};
|
||||
|
||||
// A version of GSocketManager which uses FDs for socket IO
|
||||
|
Reference in New Issue
Block a user