refactor Input/Output_Timeout: don't duplicate the same code in MSW/Unix code and also don't duplicate it for input and output, one function is enough for both

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57558 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-12-25 20:27:35 +00:00
parent e8d9821d75
commit c6b1063250
6 changed files with 62 additions and 160 deletions

View File

@@ -54,8 +54,6 @@ private:
wxSocketManager::Get()->Install_Callback(this);
}
wxSocketError Input_Timeout();
wxSocketError Output_Timeout();
wxSocketError Connect_Timeout();
int Recv_Stream(void *buffer, int size);
int Recv_Dgram(void *buffer, int size);

View File

@@ -297,6 +297,15 @@ public:
protected:
wxSocketImpl(wxSocketBase& wxsocket);
// wait until input/output becomes available or m_timeout expires
//
// returns true if we do have input/output or false on timeout or error
// (also sets m_error accordingly)
bool BlockForInputWithTimeout()
{ return DoBlockWithTimeout(wxSOCKET_INPUT_FLAG); }
bool BlockForOutputWithTimeout()
{ return DoBlockWithTimeout(wxSOCKET_OUTPUT_FLAG); }
private:
// handle the given connect() return value (which may be 0 or EWOULDBLOCK
// or something else)
@@ -338,6 +347,12 @@ private:
// update local address after binding/connecting
wxSocketError UpdateLocalAddress();
// wait for IO on the socket or until timeout expires
//
// the parameter can be one of wxSOCKET_INPUT/OUTPUT_FLAG (but could be
// their combination in the future, hence we take wxSocketEventFlags)
bool DoBlockWithTimeout(wxSocketEventFlags flags);
// set in ctor and never changed except that it's reset to NULL when the
// socket is shut down

View File

@@ -100,9 +100,6 @@ private:
void EnableEvent(wxSocketNotify event);
void DisableEvent(wxSocketNotify event);
wxSocketError Input_Timeout();
wxSocketError Output_Timeout();
int Recv_Stream(void *buffer, int size);
int Recv_Dgram(void *buffer, int size);
int Send_Stream(const void *buffer, int size);