git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57661
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
if ( !WaitForRead() )
break;
if ( !WaitForRead() )
break;
- const int ret = m_impl->Read(buffer, nbytes);
+ // m_connected will be set to false if we lost connection while
+ // waiting, there is no need to call Read() if this happened
+ const int ret = m_connected ? m_impl->Read(buffer, nbytes) : -1;
if ( ret == 0 )
{
// for connection-oriented (e.g. TCP) sockets we can only read
if ( ret == 0 )
{
// for connection-oriented (e.g. TCP) sockets we can only read
- {
- SetError(wxSOCKET_IOERR);
if ( !WaitForWrite() )
break;
if ( !WaitForWrite() )
break;
- const int ret = m_impl->Write(buffer, nbytes);
+ const int ret = m_connected ? m_impl->Write(buffer, nbytes) : -1;
if ( ret == 0 )
{
m_closed = true;
if ( ret == 0 )
{
m_closed = true;
- {
- SetError(wxSOCKET_IOERR);
total += ret;
if ( !(m_flags & wxSOCKET_WAITALL) )
total += ret;
if ( !(m_flags & wxSOCKET_WAITALL) )
{
wxCHECK_MSG( m_impl, false, "can't wait on invalid socket" );
{
wxCHECK_MSG( m_impl, false, "can't wait on invalid socket" );
+ // we're never going to become ready if we're not connected (any more)
+ if ( !m_connected && !m_establishing )
+ return (flags & wxSOCKET_LOST_FLAG) != 0;
+
// This can be set to true from Interrupt() to exit this function a.s.a.p.
m_interrupt = false;
// This can be set to true from Interrupt() to exit this function a.s.a.p.
m_interrupt = false;