From d5a065eaa8c5e5e9472201c9914c8c932bcfdf36 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Mar 2021 00:42:50 +0100 Subject: [PATCH] continued tcp server --- osal/windows/TcWinTcpServer.cpp | 15 ++++++++++++++- osal/windows/TcWinTcpServer.h | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/osal/windows/TcWinTcpServer.cpp b/osal/windows/TcWinTcpServer.cpp index 1cf7ed1d..f85147f0 100644 --- a/osal/windows/TcWinTcpServer.cpp +++ b/osal/windows/TcWinTcpServer.cpp @@ -1,5 +1,6 @@ #include "TcWinTcpServer.h" #include "../../serviceinterface/ServiceInterface.h" + #include #include @@ -90,7 +91,7 @@ TcWinTcpServer::~TcWinTcpServer() { } ReturnValue_t TcWinTcpServer::performOperation(uint8_t opCode) { - /* If a connection is accepted, the corresponding scoket will be assigned to the new socket */ + /* If a connection is accepted, the corresponding socket will be assigned to the new socket */ SOCKET clientSocket; sockaddr_in clientSockAddr; int connectorSockAddrLen = 0; @@ -113,9 +114,21 @@ ReturnValue_t TcWinTcpServer::performOperation(uint8_t opCode) { retval = recv(clientSocket, reinterpret_cast(receptionBuffer.data()), receptionBuffer.size(), 0); + if(retval > 0) { #if FSFW_TCP_SERVER_WIRETAPPING_ENABLED == 1 + sif::info << "TcWinTcpServer::performOperation: Received " << retval << " bytes." + std::endl; #endif + } + else if(retval == 0) { + } + else { + + } + + /* Done, shut down connection */ + retval = shutdown(clientSocket, SD_SEND); } return HasReturnvaluesIF::RETURN_OK; } diff --git a/osal/windows/TcWinTcpServer.h b/osal/windows/TcWinTcpServer.h index 7b679106..f8aebc53 100644 --- a/osal/windows/TcWinTcpServer.h +++ b/osal/windows/TcWinTcpServer.h @@ -10,6 +10,11 @@ //! Debugging preprocessor define. #define FSFW_TCP_SERVER_WIRETAPPING_ENABLED 0 +/** + * @brief Windows TCP server used to receive telecommands on a Windows Host + * @details + * Based on: https://docs.microsoft.com/en-us/windows/win32/winsock/complete-server-code + */ class TcWinTcpServer: public SystemObject, public ExecutableObjectIF {