simple-socket library 1.9.0
Loading...
Searching...
No Matches
TCPSocket.h
Go to the documentation of this file.
1#ifndef NET_TCPSocket_h__
2#define NET_TCPSocket_h__
3
4#include "InternetSocket.h"
5#include <optional>
6
7namespace NET
8{
11 {
12 public:
18
20
33 [[nodiscard]] static TCPSocket adoptNativeHandle( int sockfd);
34
35 // Listen for incoming connections
37
38 // Complete async connect attempt
40
42
51 void setNoDelay( bool enable);
52
54
65 [[nodiscard]] std::optional<TCPSocket> accept() const;
66
68
80 [[nodiscard]] std::optional<TCPSocket> timedAccept( int timeout) const;
81
82 // Send the complete buffer
84
85 // Receive the complete requested buffer
87
88 protected:
89 // allow construction by accept()
91 };
92
93} // namespace NET
94
95#endif // NET_TCPSocket_h__
InternetSocket(AddressFamily family, int type, int protocol)
allows a subclass to create new socket
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
std::optional< TCPSocket > timedAccept(int timeout) const
wait for another socket to connect
TCPSocket(AddressFamily family=IPv4)
static TCPSocket adoptNativeHandle(int sockfd)
Take ownership of an existing native TCP socket descriptor.
InternetSocket(AddressFamily family, int type, int protocol)
allows a subclass to create new socket
std::optional< TCPSocket > accept() const
wait for another socket to connect
void setNoDelay(bool enable)
Enable or disable TCP_NODELAY.
AddressFamily
used by internet socket types