don't duplicate GSocket creation/destruction and shutdown code in BSD and Winsock implementations
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56926 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -163,15 +163,22 @@ private:
|
||||
class GSocketBase
|
||||
{
|
||||
public:
|
||||
// static factory function
|
||||
static GSocket *Create();
|
||||
|
||||
virtual ~GSocketBase();
|
||||
|
||||
GSocketEventFlags Select(GSocketEventFlags flags);
|
||||
|
||||
virtual void Close() = 0;
|
||||
virtual void Shutdown();
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
SOCKET m_fd;
|
||||
#else
|
||||
int m_fd;
|
||||
#endif
|
||||
|
||||
bool m_ok;
|
||||
int m_initialRecvBufferSize;
|
||||
int m_initialSendBufferSize;
|
||||
|
||||
@@ -196,6 +203,9 @@ public:
|
||||
GSocketEventFlags m_detected;
|
||||
GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
|
||||
char *m_data[GSOCK_MAX_EVENT];
|
||||
|
||||
protected:
|
||||
GSocketBase();
|
||||
};
|
||||
|
||||
#if defined(__WINDOWS__)
|
||||
@@ -204,7 +214,6 @@ public:
|
||||
#include "wx/unix/gsockunx.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Global initializers */
|
||||
|
||||
/* GSocket_Init() must be called at the beginning (but after calling
|
||||
@@ -215,11 +224,6 @@ bool GSocket_Init();
|
||||
void GSocket_Cleanup();
|
||||
|
||||
|
||||
/* Constructors / Destructors */
|
||||
|
||||
GSocket *GSocket_new();
|
||||
|
||||
|
||||
/* GAddress */
|
||||
|
||||
// Represents a socket endpoint, i.e. -- in spite of its name -- not an address
|
||||
@@ -334,6 +338,13 @@ GSocketError GAddress_UNIX_GetPath(GAddress *address, char *path, size_t sbuf);
|
||||
#define SOCKOPTLEN_T int
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MSW defines this, Unices don't.
|
||||
*/
|
||||
#ifndef INVALID_SOCKET
|
||||
#define INVALID_SOCKET (-1)
|
||||
#endif
|
||||
|
||||
#endif /* wxUSE_SOCKETS */
|
||||
|
||||
#endif /* _WX_GSOCKET_H_ */
|
||||
|
@@ -27,11 +27,10 @@
|
||||
class GSocket : public GSocketBase
|
||||
{
|
||||
public:
|
||||
GSocket();
|
||||
~GSocket();
|
||||
bool IsOk() { return m_ok; }
|
||||
void Close();
|
||||
void Shutdown();
|
||||
GSocket() : GSocketBase() { m_msgnumber = 0; }
|
||||
|
||||
virtual void Close();
|
||||
|
||||
GSocketError SetLocal(GAddress *address);
|
||||
GSocketError SetPeer(GAddress *address);
|
||||
GAddress *GetLocal();
|
||||
|
@@ -17,10 +17,9 @@ class GSocket : public GSocketBase
|
||||
{
|
||||
public:
|
||||
GSocket();
|
||||
virtual ~GSocket();
|
||||
bool IsOk() { return m_ok; }
|
||||
void Close();
|
||||
void Shutdown();
|
||||
~GSocket();
|
||||
virtual void Close();
|
||||
virtual void Shutdown();
|
||||
GSocketError SetLocal(GAddress *address);
|
||||
GSocketError SetPeer(GAddress *address);
|
||||
GAddress *GetLocal();
|
||||
@@ -45,8 +44,8 @@ public:
|
||||
const void *optval, int optlen);
|
||||
//attach or detach from main loop
|
||||
void Notify(bool flag);
|
||||
virtual void Detected_Read();
|
||||
virtual void Detected_Write();
|
||||
void Detected_Read();
|
||||
void Detected_Write();
|
||||
void SetInitialSocketBuffers(int recv, int send)
|
||||
{
|
||||
m_initialRecvBufferSize = recv;
|
||||
|
Reference in New Issue
Block a user