2021-03-21 00:30:33 +01:00
|
|
|
#ifndef FSFW_OSAL_COMMON_TCPIPIF_H_
|
|
|
|
#define FSFW_OSAL_COMMON_TCPIPIF_H_
|
|
|
|
|
2021-05-12 16:47:53 +02:00
|
|
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
|
|
|
#include "../../platform.h"
|
2021-03-21 00:30:33 +01:00
|
|
|
|
2021-05-12 16:47:53 +02:00
|
|
|
#ifdef PLATFORM_WIN
|
2021-03-21 00:30:33 +01:00
|
|
|
|
|
|
|
#include <winsock2.h>
|
|
|
|
|
2021-05-12 16:47:53 +02:00
|
|
|
#elif defined(PLATFORM_UNIX)
|
2021-03-21 00:30:33 +01:00
|
|
|
|
2021-03-21 12:51:28 +01:00
|
|
|
#include <sys/socket.h>
|
2021-03-21 00:30:33 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class TcpIpBase {
|
|
|
|
protected:
|
|
|
|
|
2021-05-12 16:47:53 +02:00
|
|
|
#ifdef PLATFORM_WIN
|
2021-03-21 00:30:33 +01:00
|
|
|
static constexpr int SHUT_RECV = SD_RECEIVE;
|
|
|
|
static constexpr int SHUT_SEND = SD_SEND;
|
|
|
|
static constexpr int SHUT_BOTH = SD_BOTH;
|
|
|
|
|
|
|
|
using socket_t = SOCKET;
|
|
|
|
#elif defined(__unix__)
|
|
|
|
using socket_t = int;
|
|
|
|
|
|
|
|
static constexpr int INVALID_SOCKET = -1;
|
|
|
|
static constexpr int SOCKET_ERROR = -1;
|
|
|
|
|
|
|
|
static constexpr int SHUT_RECV = SHUT_RD;
|
|
|
|
static constexpr int SHUT_SEND = SHUT_WR;
|
|
|
|
static constexpr int SHUT_BOTH = SHUT_RDWR;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
TcpIpBase();
|
|
|
|
virtual ~TcpIpBase();
|
|
|
|
|
|
|
|
ReturnValue_t initialize();
|
|
|
|
|
|
|
|
int closeSocket(socket_t socket);
|
|
|
|
|
|
|
|
int getLastSocketError();
|
|
|
|
|
|
|
|
socket_t serverSocket = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FSFW_OSAL_COMMON_TCPIPIF_H_ */
|