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;
46 typedef void raw_type;
91 int send(
const void* buffer,
size_t len);
117 int receive(
void* buffer,
size_t len);
144 int timedReceive(
void* buffer,
size_t len,
int timeout);
211 void listen(
int backlog = 5);
231 int sendAll( const
void* buffer,
size_t len);
267 bool m_peerDisconnected;
268 bool m_connectionOriented;
A socket representing a basic communication endpoint.
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 accept() const
allows stream sockets to accept connections into Handles
int receiveAll(void *buffer, size_t len)
receive exactly the requested amount unless the peer disconnects
void listen(int backlog=5)
listen for incoming connections
void shutdown(ShutdownDirection type)
shutdown the connection in the specified direction
int sendAll(const void *buffer, size_t len)
send data through a connected socket
int send(const void *buffer, size_t len)
send data through a connected socket
int nativeHandle() noexcept
return the native handle of the open 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
bool peerDisconnected() const noexcept
returns whether a currently associated peer disconnected
int timedAccept(int timeout) const
allows stream sockets timed accept
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() noexcept
Provided just to guarantee that no exceptions are thrown.
int errorCode() const noexcept
Returns the glibc errno code of the current error.