simple-socket library 1.9.0
Loading...
Searching...
No Matches
UnixStreamSocket.h
Go to the documentation of this file.
1#ifndef NET_UnixStreamSocket_h__
2#define NET_UnixStreamSocket_h__
3
4#include "UnixSocket.h"
5#include <optional>
6
7namespace NET
8{
11 {
12 public:
18
20
34 [[nodiscard]] static UnixStreamSocket adoptNativeHandle( int sockfd);
35
40 [[nodiscard]] static std::pair<UnixStreamSocket, UnixStreamSocket>
41 createPair( bool nonBlocking = false);
42
43 // Listen for incoming connections
45
46 // Complete async connect attempt
48
59 [[nodiscard]] std::optional<UnixStreamSocket> accept() const;
60
70 [[nodiscard]] std::optional<UnixStreamSocket> timedAccept( int timeout) const;
71
72 // Send the complete buffer
74
75 // Receive the complete requested buffer
77
78 protected:
79 // allow construction by accept()
81 };
82
83} // namespace NET
84
85#endif // NET_UnixStreamSocket_h__
IOResult receiveAll(void *buffer, size_t len)
receive exactly the requested amount unless the peer disconnects
void listen(int backlog=128)
listen for incoming connections
IOResult sendAll(const void *buffer, size_t len)
send data through a connected socket
ConnectResult finishConnect(int timeout=0)
check if a previously started connected attempt is finished
UnixSocket(int type, int protocol)
allows a subclass to create new socket
UnixSocket(int type, int protocol)
allows a subclass to create new socket
static UnixStreamSocket adoptNativeHandle(int sockfd)
Take ownership of an existing native Unix stream socket descriptor.
std::optional< UnixStreamSocket > accept() const
static std::pair< UnixStreamSocket, UnixStreamSocket > createPair(bool nonBlocking=false)
std::optional< UnixStreamSocket > timedAccept(int timeout) const