|
| UDPSocket () |
| Default: construct an unbound, unconnected UDP socket. More...
|
|
received_datagram | recv (const size_t mtu=65536) |
| Receive a datagram and the Address of its sender. More...
|
|
void | recv (received_datagram &datagram, const size_t mtu=65536) |
| Receive a datagram and the Address of its sender (caller can allocate storage) More...
|
|
void | send (const BufferViewList &payload) |
| Send datagram to the socket's connected address (must call connect() first) More...
|
|
void | sendto (const Address &destination, const BufferViewList &payload) |
| Send a datagram to specified Address. More...
|
|
void | bind (const Address &address) |
| Bind a socket to a specified address with bind(2), usually for listen/accept. More...
|
|
void | connect (const Address &address) |
| Connect a socket to a specified peer address with connect(2). More...
|
|
Address | local_address () const |
| Get local address of socket with getsockname(2). More...
|
|
Address | peer_address () const |
| Get peer address of socket with getpeername(2). More...
|
|
void | set_reuseaddr () |
| Allow local address to be reused sooner via SO_REUSEADDR. More...
|
|
void | shutdown (const int how) |
| Shut down a socket via shutdown(2). More...
|
|
| FileDescriptor (const int fd) |
| Construct from a file descriptor number returned by the kernel. More...
|
|
| ~FileDescriptor ()=default |
| Free the std::shared_ptr; the FDWrapper destructor calls close() when the refcount goes to zero. More...
|
|
void | close () |
| Close the underlying file descriptor. More...
|
|
FileDescriptor | duplicate () const |
| Copy a FileDescriptor explicitly, increasing the FDWrapper refcount. More...
|
|
std::string | read (const size_t limit=std::numeric_limits< size_t >::max()) |
| Read up to limit bytes. More...
|
|
void | read (std::string &str, const size_t limit=std::numeric_limits< size_t >::max()) |
| Read up to limit bytes into str (caller can allocate storage) More...
|
|
void | set_blocking (const bool blocking_state) |
| Set blocking(true) or non-blocking(false) More...
|
|
size_t | write (BufferViewList buffer, const bool write_all=true) |
| Write a buffer (or list of buffers), possibly blocking until all is written. More...
|
|
size_t | write (const char *str, const bool write_all=true) |
| Write a string, possibly blocking until all is written. More...
|
|
size_t | write (const std::string &str, const bool write_all=true) |
| Write a string, possibly blocking until all is written. More...
|
|
int | fd_num () const |
| underlying descriptor number More...
|
|
bool | eof () const |
| EOF flag state. More...
|
|
bool | closed () const |
| closed flag state More...
|
|
unsigned int | read_count () const |
| number of reads More...
|
|
unsigned int | write_count () const |
| number of writes More...
|
|
| FileDescriptor (const FileDescriptor &other)=delete |
| copy construction is forbidden More...
|
|
FileDescriptor & | operator= (const FileDescriptor &other)=delete |
| copy assignment is forbidden More...
|
|
| FileDescriptor (FileDescriptor &&other)=default |
| move construction is allowed More...
|
|
FileDescriptor & | operator= (FileDescriptor &&other)=default |
| move assignment is allowed More...
|
|
A wrapper around UDP sockets.
Functions in this class are essentially wrappers over their POSIX eponyms.
Example:
if (
recvd.payload !=
"hi there" ||
recvd2.payload !=
"hi yourself") {
}
Wrapper around IPv4 addresses and DNS operations.
void connect(const Address &address)
Connect a socket to a specified peer address with connect(2).
void bind(const Address &address)
Bind a socket to a specified address with bind(2), usually for listen/accept.
A wrapper around UDP sockets.
received_datagram recv(const size_t mtu=65536)
Receive a datagram and the Address of its sender.
void send(const BufferViewList &payload)
Send datagram to the socket's connected address (must call connect() first)
void sendto(const Address &destination, const BufferViewList &payload)
Send a datagram to specified Address.
Definition at line 51 of file socket.hh.