10Duke Enterprise C++ SDK
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
43 virtual void bind(
44 std::uint32_t ipAddress,
45 std::uint16_t port
46 ) = 0;
47
52 virtual void listen() = 0;
53
61 virtual int read(void * buffer, std::size_t bufferSize) = 0;
62
70 virtual int write(const void * buffer, std::size_t len) = 0;
71
76 virtual std::uint16_t getPort() const = 0;
77
82 virtual void setNonBlocking() = 0;
83};
84
85}}
86
87#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 void bind(std::uint32_t ipAddress, std::uint16_t port)=0
Binds 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.
Operating system abstraction.
Definition win32_utils.h:7
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4