fix handling of wxSOCKET_REUSEADDR in wxDatagramSocket (patch 1667145)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44661 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -64,6 +64,7 @@ All:
|
|||||||
- Added wxSearchCtrl::[Get|Set]DescriptiveText.
|
- Added wxSearchCtrl::[Get|Set]DescriptiveText.
|
||||||
- Fixed detection of number of processors under Linux 2.6
|
- Fixed detection of number of processors under Linux 2.6
|
||||||
- Fixed Base64 computation in wxHTTP (p_michalczyk)
|
- Fixed Base64 computation in wxHTTP (p_michalczyk)
|
||||||
|
- Fix handling of wxSOCKET_REUSEADDR in wxDatagramSocket (troelsk)
|
||||||
|
|
||||||
wxMSW
|
wxMSW
|
||||||
|
|
||||||
|
@@ -1344,14 +1344,18 @@ wxDatagramSocket::wxDatagramSocket( const wxSockAddress& addr,
|
|||||||
// Create the socket
|
// Create the socket
|
||||||
m_socket = GSocket_new();
|
m_socket = GSocket_new();
|
||||||
|
|
||||||
if(!m_socket)
|
if (!m_socket)
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( _T("datagram socket not new'd") );
|
wxFAIL_MSG( _T("datagram socket not new'd") );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Setup the socket as non connection oriented
|
// Setup the socket as non connection oriented
|
||||||
m_socket->SetLocal(addr.GetAddress());
|
m_socket->SetLocal(addr.GetAddress());
|
||||||
if( m_socket->SetNonOriented() != GSOCK_NOERROR )
|
if (flags & wxSOCKET_REUSEADDR)
|
||||||
|
{
|
||||||
|
m_socket->SetReusable();
|
||||||
|
}
|
||||||
|
if ( m_socket->SetNonOriented() != GSOCK_NOERROR )
|
||||||
{
|
{
|
||||||
delete m_socket;
|
delete m_socket;
|
||||||
m_socket = NULL;
|
m_socket = NULL;
|
||||||
|
@@ -399,8 +399,9 @@ GSocketError GSocket::SetServer()
|
|||||||
/* allow a socket to re-bind if the socket is in the TIME_WAIT
|
/* allow a socket to re-bind if the socket is in the TIME_WAIT
|
||||||
state after being previously closed.
|
state after being previously closed.
|
||||||
*/
|
*/
|
||||||
if (m_reusable) {
|
if (m_reusable)
|
||||||
setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&arg, sizeof(u_long));
|
{
|
||||||
|
setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&arg, sizeof(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bind to the local address,
|
/* Bind to the local address,
|
||||||
@@ -596,7 +597,7 @@ GSocketError GSocket::Connect(GSocketStream stream)
|
|||||||
// If the reuse flag is set, use the applicable socket reuse flag
|
// If the reuse flag is set, use the applicable socket reuse flag
|
||||||
if (m_reusable)
|
if (m_reusable)
|
||||||
{
|
{
|
||||||
setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&arg, sizeof(u_long));
|
setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&arg, sizeof(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a local address has been set, then we need to bind to it before calling connect
|
// If a local address has been set, then we need to bind to it before calling connect
|
||||||
@@ -701,6 +702,11 @@ GSocketError GSocket::SetNonOriented()
|
|||||||
ioctlsocket(m_fd, FIONBIO, (u_long FAR *) &arg);
|
ioctlsocket(m_fd, FIONBIO, (u_long FAR *) &arg);
|
||||||
gs_gui_functions->Enable_Events(this);
|
gs_gui_functions->Enable_Events(this);
|
||||||
|
|
||||||
|
if (m_reusable)
|
||||||
|
{
|
||||||
|
setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&arg, sizeof(arg));
|
||||||
|
}
|
||||||
|
|
||||||
/* Bind to the local address,
|
/* Bind to the local address,
|
||||||
* and retrieve the actual address bound.
|
* and retrieve the actual address bound.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user