diff --git a/lib/tcpip/fnTcpClient.cpp b/lib/tcpip/fnTcpClient.cpp index 073c1c746..b6f0e2708 100644 --- a/lib/tcpip/fnTcpClient.cpp +++ b/lib/tcpip/fnTcpClient.cpp @@ -57,9 +57,8 @@ class fnTcpClientSocketHandle fnTcpClient::fnTcpClient(int fd) { - _fd = fd; _connected = true; - _clientSocketHandle.reset(new fnTcpClientSocketHandle(_fd)); + _clientSocketHandle.reset(new fnTcpClientSocketHandle(fd)); _rxBuffer.clear(); } @@ -432,23 +431,24 @@ void fnTcpClient::updateFIFO() #if defined(_WIN32) unsigned long count; - int res = ioctlsocket(_fd, FIONREAD, &count); + int res = ioctlsocket(fd(), FIONREAD, &count); res = res != 0 ? -1 : count; #else int count; - int res = ioctl(_fd, FIONREAD, &count); + int res = ioctl(fd(), FIONREAD, &count); res = res < 0 ? -1 : count; #endif if (res > 0) { ssize_t result; + unsigned count; for (count = res; count; count -= result) { size_t old_len = _rxBuffer.size(); _rxBuffer.resize(old_len + count); - result = recv(_fd, &_rxBuffer[old_len], count, 0); + result = recv(fd(), &_rxBuffer[old_len], count, 0); if (result < 0) result = 0; _rxBuffer.resize(old_len + result); @@ -484,7 +484,7 @@ void fnTcpClient::flush() res = recv(fd(), (char *)buf, toRead, MSG_DONTWAIT); if (res < 0) { - Debug_printf("fail on fd %d, errno: %d, \"%s\"\r\n", + Debug_printf("fail on fd %d, errno: %d, \"%s\"\r\n", fd(), compat_getsockerr(), compat_sockstrerror(compat_getsockerr())); stop(); break; diff --git a/lib/tcpip/fnTcpClient.h b/lib/tcpip/fnTcpClient.h index 607136fbe..14de3a4b1 100644 --- a/lib/tcpip/fnTcpClient.h +++ b/lib/tcpip/fnTcpClient.h @@ -14,7 +14,6 @@ class fnTcpClient { protected: std::string _rxBuffer; - int _fd; std::shared_ptr _clientSocketHandle; bool _connected = false;