Index: src/OFStream.h ================================================================== --- src/OFStream.h +++ src/OFStream.h @@ -84,11 +84,11 @@ #ifdef OF_HAVE_SOCKETS OFReadyForReadingObserving, OFReadyForWritingObserving, #endif OFCopying> { -#ifndef OF_SEEKABLE_STREAM_M +#if !defined(OF_SEEKABLE_STREAM_M) && !defined(OF_TCP_SOCKET_M) @private #endif char *_readBuffer, *_writeBuffer; size_t _readBufferLength, _writeBufferLength; bool _writeBufferEnabled, _waitingForDelimiter; Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -12,10 +12,12 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ +#define OF_TCP_SOCKET_M + #define __NO_EXT_QNX #include "config.h" #include @@ -269,10 +271,17 @@ of_resolver_result_t **results, **iter; if (_socket != INVALID_SOCKET) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; + _listening = false; + + /* Make sure to clear the read buffer in case the socket is reused */ + [self freeMemory: _readBuffer]; + _readBuffer = NULL; + _readBufferLength = 0; + if (_SOCKS5Host != nil) { /* Connect to the SOCKS5 proxy instead */ host = _SOCKS5Host; port = _SOCKS5Port; } @@ -513,13 +522,6 @@ - (bool)isListening { return _listening; } - -- (void)close -{ - [super close]; - - _listening = false; -} @end