X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/28bf2f3c66b38f65ab98881610b90639f8ef18cc..69659fd770f615210efac4b4fa741b3ad6223616:/src/common/socket.cpp diff --git a/src/common/socket.cpp b/src/common/socket.cpp index e36bfe9768..e90a3b7cb5 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -39,7 +39,7 @@ #include "wx/apptrait.h" #include "wx/sckaddr.h" -#include "wx/datetime.h" +#include "wx/stopwatch.h" // DLL options compatibility check: #include "wx/build.h" @@ -680,7 +680,7 @@ bool wxSocketBase::_Wait(long seconds, wxSocketEventFlags flags) { GSocketEventFlags result; - long timeout; + long timeout; // in ms // Set this to true to interrupt ongoing waits m_interrupt = false; @@ -707,8 +707,7 @@ bool wxSocketBase::_Wait(long seconds, // Do this at least once (important if timeout == 0, when // we are just polling). Also, if just polling, do not yield. - wxDateTime current_time = wxDateTime::UNow(); - unsigned int time_limit = (current_time.GetTicks() * 1000) + current_time.GetMillisecond() + timeout; + const wxMilliClock_t time_limit = wxGetLocalTimeMillis() + timeout; bool done = false; bool valid_result = false; @@ -752,8 +751,7 @@ bool wxSocketBase::_Wait(long seconds, } // Wait more? - current_time = wxDateTime::UNow(); - int time_left = time_limit - ((current_time.GetTicks() * 1000) + current_time.GetMillisecond()); + long time_left = wxMilliClockToLong(time_limit - wxGetLocalTimeMillis()); if ((!timeout) || (time_left <= 0) || (m_interrupt)) done = true; else @@ -1105,6 +1103,12 @@ wxSocketServer::wxSocketServer(const wxSockAddress& addr_man, if (GetFlags() & wxSOCKET_REUSEADDR) { m_socket->SetReusable(); } + if (GetFlags() & wxSOCKET_BROADCAST) { + m_socket->SetBroadcast(); + } + if (GetFlags() & wxSOCKET_NOBIND) { + m_socket->DontDoBind(); + } if (m_socket->SetServer() != GSOCK_NOERROR) { @@ -1275,6 +1279,14 @@ bool wxSocketClient::DoConnect(wxSockAddress& addr_man, wxSockAddress* local, bo { m_socket->SetReusable(); } + if (GetFlags() & wxSOCKET_BROADCAST) + { + m_socket->SetBroadcast(); + } + if (GetFlags() & wxSOCKET_NOBIND) + { + m_socket->DontDoBind(); + } // If no local address was passed and one has been set, use the one that was Set if (!local && m_localAddress.GetAddress()) @@ -1355,6 +1367,14 @@ wxDatagramSocket::wxDatagramSocket( const wxSockAddress& addr, { m_socket->SetReusable(); } + if (GetFlags() & wxSOCKET_BROADCAST) + { + m_socket->SetBroadcast(); + } + if (GetFlags() & wxSOCKET_NOBIND) + { + m_socket->DontDoBind(); + } if ( m_socket->SetNonOriented() != GSOCK_NOERROR ) { delete m_socket;