continued tcp server
This commit is contained in:
parent
b695242420
commit
d5a065eaa8
@ -1,5 +1,6 @@
|
|||||||
#include "TcWinTcpServer.h"
|
#include "TcWinTcpServer.h"
|
||||||
#include "../../serviceinterface/ServiceInterface.h"
|
#include "../../serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ TcWinTcpServer::~TcWinTcpServer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t TcWinTcpServer::performOperation(uint8_t opCode) {
|
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;
|
SOCKET clientSocket;
|
||||||
sockaddr_in clientSockAddr;
|
sockaddr_in clientSockAddr;
|
||||||
int connectorSockAddrLen = 0;
|
int connectorSockAddrLen = 0;
|
||||||
@ -113,9 +114,21 @@ ReturnValue_t TcWinTcpServer::performOperation(uint8_t opCode) {
|
|||||||
|
|
||||||
retval = recv(clientSocket, reinterpret_cast<char*>(receptionBuffer.data()),
|
retval = recv(clientSocket, reinterpret_cast<char*>(receptionBuffer.data()),
|
||||||
receptionBuffer.size(), 0);
|
receptionBuffer.size(), 0);
|
||||||
|
if(retval > 0) {
|
||||||
#if FSFW_TCP_SERVER_WIRETAPPING_ENABLED == 1
|
#if FSFW_TCP_SERVER_WIRETAPPING_ENABLED == 1
|
||||||
|
sif::info << "TcWinTcpServer::performOperation: Received " << retval << " bytes."
|
||||||
|
std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
else if(retval == 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Done, shut down connection */
|
||||||
|
retval = shutdown(clientSocket, SD_SEND);
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
//! Debugging preprocessor define.
|
//! Debugging preprocessor define.
|
||||||
#define FSFW_TCP_SERVER_WIRETAPPING_ENABLED 0
|
#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:
|
class TcWinTcpServer:
|
||||||
public SystemObject,
|
public SystemObject,
|
||||||
public ExecutableObjectIF {
|
public ExecutableObjectIF {
|
||||||
|
Loading…
Reference in New Issue
Block a user