10Duke Scale C++ Client
Loading...
Searching...
No Matches
Socket.h
1#ifndef TENDUKE_OSA_SOCKET_H
2#define TENDUKE_OSA_SOCKET_H
3
4#include <cstdint>
5#include <memory>
6
7namespace tenduke { namespace osa {
8
13class Socket
14{
15public:
16 virtual ~Socket() = default;
17
29 virtual std::unique_ptr<Socket> accept(uint32_t timeoutMs) = 0;
30
36 virtual std::unique_ptr<Socket> accept() = 0;
37
42 virtual void listen() = 0;
43
51 virtual int read(void * buffer, std::size_t bufferSize) = 0;
52
60 virtual int write(const void * buffer, std::size_t len) = 0;
61
66 virtual std::uint16_t getPort() const = 0;
67
72 virtual void setNonBlocking() = 0;
73};
74
75}}
76
77#endif //TENDUKE_OSA_SOCKET_H
OS-independent abstraction of a socket.
Definition Socket.h:14
virtual int write(const void *buffer, std::size_t len)=0
Write bytes to the socket.
virtual int read(void *buffer, std::size_t bufferSize)=0
Reads bytes from the socket.
virtual void setNonBlocking()=0
Sets the socket to non-blocking mode.
virtual std::unique_ptr< Socket > accept()=0
Accepts next connection from listening socket.
virtual std::unique_ptr< Socket > accept(uint32_t timeoutMs)=0
Accepts next connection from listening socket, with a timeout.
virtual std::uint16_t getPort() const =0
Returns port of the socket.
virtual void listen()=0
Configures the socket to listen for incoming connections.
Root for classes, functions and globals of 10Duke C++ Client.
Definition BackendConfiguration.h:7