use struct timeval and not a long to store socket timeout under Unix too
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56940 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -37,6 +37,8 @@ class WXDLLIMPEXP_FWD_NET wxSocketBase;
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <time.h> // for timeval
|
||||||
|
|
||||||
enum GAddressType
|
enum GAddressType
|
||||||
{
|
{
|
||||||
GSOCK_NOFAMILY = 0,
|
GSOCK_NOFAMILY = 0,
|
||||||
@@ -215,11 +217,7 @@ public:
|
|||||||
bool m_broadcast;
|
bool m_broadcast;
|
||||||
bool m_dobind;
|
bool m_dobind;
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
|
||||||
struct timeval m_timeout;
|
struct timeval m_timeout;
|
||||||
#else
|
|
||||||
unsigned long m_timeout;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GSocketEventFlags m_detected;
|
GSocketEventFlags m_detected;
|
||||||
|
|
||||||
|
@@ -231,12 +231,8 @@ void GSocketBase::Shutdown()
|
|||||||
*/
|
*/
|
||||||
void GSocketBase::SetTimeout(unsigned long millis)
|
void GSocketBase::SetTimeout(unsigned long millis)
|
||||||
{
|
{
|
||||||
#ifdef __WXMSW__
|
|
||||||
m_timeout.tv_sec = (millis / 1000);
|
m_timeout.tv_sec = (millis / 1000);
|
||||||
m_timeout.tv_usec = (millis % 1000) * 1000;
|
m_timeout.tv_usec = (millis % 1000) * 1000;
|
||||||
#else
|
|
||||||
m_timeout = millis;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSocketBase::NotifyOnStateChange(GSocketEvent event)
|
void GSocketBase::NotifyOnStateChange(GSocketEvent event)
|
||||||
|
@@ -1161,13 +1161,11 @@ void GSocket::Disable(GSocketEvent event)
|
|||||||
*/
|
*/
|
||||||
GSocketError GSocket::Input_Timeout()
|
GSocketError GSocket::Input_Timeout()
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
|
||||||
fd_set readfds;
|
fd_set readfds;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Linux select() will overwrite the struct on return */
|
// Linux select() will overwrite the struct on return so make a copy
|
||||||
tv.tv_sec = (m_timeout / 1000);
|
struct timeval tv = m_timeout;
|
||||||
tv.tv_usec = (m_timeout % 1000) * 1000;
|
|
||||||
|
|
||||||
if (!m_non_blocking)
|
if (!m_non_blocking)
|
||||||
{
|
{
|
||||||
@@ -1202,13 +1200,11 @@ GSocketError GSocket::Input_Timeout()
|
|||||||
*/
|
*/
|
||||||
GSocketError GSocket::Output_Timeout()
|
GSocketError GSocket::Output_Timeout()
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
|
||||||
fd_set writefds;
|
fd_set writefds;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Linux select() will overwrite the struct on return */
|
// Linux select() will overwrite the struct on return so make a copy
|
||||||
tv.tv_sec = (m_timeout / 1000);
|
struct timeval tv = m_timeout;
|
||||||
tv.tv_usec = (m_timeout % 1000) * 1000;
|
|
||||||
|
|
||||||
GSocket_Debug( ("m_non_blocking has: %d\n", (int)m_non_blocking) );
|
GSocket_Debug( ("m_non_blocking has: %d\n", (int)m_non_blocking) );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user