fsfw/osal/common/TcpIpBase.h

48 lines
996 B
C
Raw Normal View History

#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-05-12 16:47:53 +02:00
#ifdef PLATFORM_WIN
#include <winsock2.h>
2021-05-12 16:47:53 +02:00
#elif defined(PLATFORM_UNIX)
2021-03-21 12:51:28 +01:00
#include <sys/socket.h>
#endif
class TcpIpBase {
protected:
2021-05-12 16:47:53 +02:00
#ifdef PLATFORM_WIN
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;
2021-05-12 17:32:40 +02:00
#elif defined(PLATFORM_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_ */