Incorporated src/unix/gsocket.c 1.86 to 1.92 changes (except 1.90 to 1.91
which was applied by Vadim as 1.9 to 1.10 of src/unix/gsocket.cpp) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28515 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -44,6 +44,7 @@ public:
|
||||
GAddress *GetPeer();
|
||||
GSocketError SetServer();
|
||||
GSocket *WaitConnection();
|
||||
int SetReusable();
|
||||
GSocketError Connect(GSocketStream stream);
|
||||
GSocketError SetNonOriented();
|
||||
int Read(char *buffer, int size);
|
||||
@@ -55,6 +56,9 @@ public:
|
||||
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);
|
||||
/* API compatibility functions */
|
||||
static void _GSocket_Detected_Read(GSocket *socket);
|
||||
static void _GSocket_Detected_Write(GSocket *socket);
|
||||
@@ -172,6 +176,8 @@ inline GSocketError GSocket_SetServer(GSocket *socket)
|
||||
{ return socket->SetServer(); }
|
||||
inline GSocket *GSocket_WaitConnection(GSocket *socket)
|
||||
{ return socket->WaitConnection(); }
|
||||
inline int GSocket_SetReusable(GSocket *socket)
|
||||
{ return socket->SetReusable(); }
|
||||
inline GSocketError GSocket_Connect(GSocket *socket, GSocketStream stream)
|
||||
{ return socket->Connect(stream); }
|
||||
inline GSocketError GSocket_SetNonOriented(GSocket *socket)
|
||||
@@ -191,6 +197,12 @@ inline void GSocket_SetCallback(GSocket *socket, GSocketEventFlags flags,
|
||||
{ socket->SetCallback(flags,fallback,cdata); }
|
||||
inline void GSocket_UnsetCallback(GSocket *socket, GSocketEventFlags flags)
|
||||
{ socket->UnsetCallback(flags); }
|
||||
inline GSocketError GSocket_GetSockOpt(GSocket *socket, int level, int optname,
|
||||
void *optval, int *optlen)
|
||||
{ return socket->GetSockOpt(level,optname,optval,optlen); }
|
||||
inline GSocketError GSocket_SetSockOpt(GSocket *socket, int level, int optname,
|
||||
const void *optval, int optlen)
|
||||
{ return socket->SetSockOpt(level,optname,optval,optlen); }
|
||||
|
||||
#endif /* def wxUSE_GSOCKET_CPLUSPLUS */
|
||||
|
||||
|
@@ -475,6 +475,7 @@ GSocketError GSocketBSD::SetServer()
|
||||
/* allow a socket to re-bind if the socket is in the TIME_WAIT
|
||||
state after being previously closed.
|
||||
*/
|
||||
if(m_reusable)
|
||||
setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&arg, sizeof(u_long));
|
||||
|
||||
/* Bind to the local address,
|
||||
@@ -588,6 +589,16 @@ GSocket *GSocketBSD::WaitConnection()
|
||||
return connection;
|
||||
}
|
||||
|
||||
int GSocketBSD::SetReusable()
|
||||
{
|
||||
/* socket must not be null, and must not be in use/already bound */
|
||||
if (NULL != this && m_fd == INVALID_SOCKET) {
|
||||
m_reusable = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Client specific parts */
|
||||
|
||||
/* GSocket_Connect:
|
||||
@@ -1117,6 +1128,26 @@ void GSocketBSD::UnsetCallback(GSocketEventFlags flags)
|
||||
}
|
||||
|
||||
|
||||
GSocketError GSocketBSD::GetSockOpt(int level, int optname,
|
||||
void *optval, int *optlen)
|
||||
{
|
||||
if (getsockopt(m_fd, level, optname, optval, optlen) == 0)
|
||||
{
|
||||
return GSOCK_NOERROR;
|
||||
}
|
||||
return GSOCK_OPTERR;
|
||||
}
|
||||
|
||||
GSocketError GSocketBSD::SetSockOpt(int level, int optname,
|
||||
const void *optval, int optlen)
|
||||
{
|
||||
if (setsockopt(m_fd, level, optname, optval, optlen) == 0)
|
||||
{
|
||||
return GSOCK_NOERROR;
|
||||
}
|
||||
return GSOCK_OPTERR;
|
||||
}
|
||||
|
||||
#define CALL_CALLBACK(event) { \
|
||||
Disable(event); \
|
||||
if (m_cbacks[event]) \
|
||||
|
Reference in New Issue
Block a user