Add missing shutdown/close

This commit is contained in:
Maschell 2022-03-05 17:46:11 +01:00
parent 3cf879dee7
commit 37d42d27ad

View File

@ -39,6 +39,8 @@ TcpReceiver::~TcpReceiver() {
if (serverSocket >= 0) { if (serverSocket >= 0) {
shutdown(serverSocket, SHUT_RDWR); shutdown(serverSocket, SHUT_RDWR);
close(serverSocket);
serverSocket = -1;
} }
} }
@ -62,12 +64,16 @@ void TcpReceiver::executeThread() {
socklen_t len; socklen_t len;
int32_t ret; int32_t ret;
if ((ret = bind(serverSocket, (struct sockaddr *) &bindAddress, 16)) < 0) { if ((ret = bind(serverSocket, (struct sockaddr *) &bindAddress, 16)) < 0) {
shutdown(serverSocket, SHUT_RDWR);
close(serverSocket); close(serverSocket);
serverSocket = -1;
return; return;
} }
if ((ret = listen(serverSocket, 1)) < 0) { if ((ret = listen(serverSocket, 1)) < 0) {
shutdown(serverSocket, SHUT_RDWR);
close(serverSocket); close(serverSocket);
serverSocket = -1;
return; return;
} }
@ -94,7 +100,9 @@ void TcpReceiver::executeThread() {
} }
} }
shutdown(serverSocket, SHUT_RDWR);
close(serverSocket); close(serverSocket);
serverSocket = -1;
} }
int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {