Add per-direction wxSocket wait flags and byte counters.

Allow to specify whether the socket should block until all the data is read or
written or, on the contrary, avoid blocking only when reading or writing
instead of always using the same behaviour in both directions.

Also add separate counters for the bytes read/written instead of using the
same one for both.

These changes make it possible to use the same socket for reading/writing in
different threads.

Closes #14506.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72591 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-09-30 22:21:44 +00:00
parent be4162218d
commit 294a09aa8c
5 changed files with 150 additions and 26 deletions

View File

@@ -186,6 +186,7 @@ void SocketTestCase::ReadNormal()
CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() );
CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), (size_t)sock->LastCount() );
CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), (size_t)sock->LastReadCount() );
char bufBig[102400];
@@ -193,6 +194,7 @@ void SocketTestCase::ReadNormal()
CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() );
CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastCount() );
CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastReadCount() );
}
void SocketTestCase::ReadBlock()
@@ -206,6 +208,7 @@ void SocketTestCase::ReadBlock()
CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() );
CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), (size_t)sock->LastCount() );
CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), (size_t)sock->LastReadCount() );
char bufBig[102400];
@@ -213,6 +216,7 @@ void SocketTestCase::ReadBlock()
CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() );
CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastCount() );
CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastReadCount() );
}
void SocketTestCase::ReadNowait()
@@ -242,6 +246,7 @@ void SocketTestCase::ReadWaitall()
CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() );
CPPUNIT_ASSERT_EQUAL( WXSIZEOF(buf), (size_t)sock->LastCount() );
CPPUNIT_ASSERT_EQUAL( WXSIZEOF(buf), (size_t)sock->LastReadCount() );
}
void SocketTestCase::UrlTest()