28 typedef int socklen_t;
29#elif defined(OS_POSIX)
31 static SOCKET
const INVALID_SOCKET = -1;
35 enum class State { Invalid, Listening, Connected };
48 void close()
override;
51 inline bool valid()
const {
return (_handle != INVALID_SOCKET); }
54 inline bool listening()
const {
return (_state == State::Listening); }
55 inline bool connected()
const override {
56 return (_state == State::Connected);
63 bool listen(std::string
const &address, std::string
const &port);
65 bool listen(std::string
const &path,
bool abstract =
false);
67 std::unique_ptr<Socket> accept();
68 bool connect(std::string
const &host, std::string
const &port);
71 bool getSocketInfo(
struct sockaddr_storage *ss)
const;
74 std::string address()
const;
75 std::string port()
const;
78 std::string error()
const;
81 bool wait(
int ms = -1)
override;
84 bool setNonBlocking();
87 ssize_t send(
void const *buffer,
size_t length)
override;
88 ssize_t receive(
void *buffer,
size_t length)
override;