1#ifndef NET_SimpleSocket_h__
2#define NET_SimpleSocket_h__
28 const char*
what() const noexcept {
return m_message.c_str(); }
31 int errorCode() const noexcept {
return m_errorcode; }
34 std::string m_message;
40 typedef void raw_type;
84 int send(
const void* buffer,
size_t len);
SocketException(std::string_view message, bool inclSysMsg=true)
const char * what() const noexcept
Returns a C-string describing the cause of the current error.
SocketException(const SocketException &)=default
~SocketException() noexcept
Provided just to guarantee that no exceptions are thrown.
int errorCode() const noexcept
Returns the glibc errno code of the current error.
int timedReceive(void *buffer, size_t len, int timeout)
receive data from a bound socket, return after the given timespan
void disconnect()
Disconnect and unset any foreign addresses.
int nativeHandle()
return the native handle of the open socket
void shutdown(ShutdownDirection type)
shutdown the connection in the specified direction
int send(const void *buffer, size_t len)
send data through a connected socket
bool peerDisconnected() const
returns whether a peer disconnected
SimpleSocket(int sockfd)
enables return of an accepted socket
@ STOP_RECEIVE
disable all variants of receive() on the socket, send calls still work
@ STOP_SEND
disable all variants of send() on the socket, receive calls still work
@ STOP_BOTH
disable all send() and receive() calls on the socket
int receive(void *buffer, size_t len)
receive data from a bound socket