Derecho  0.9
Distributed systems toolkit for RDMA
Public Member Functions | Private Attributes | List of all members
tcp::connection_listener Class Reference

#include <tcp.hpp>

Collaboration diagram for tcp::connection_listener:
Collaboration graph
[legend]

Public Member Functions

 connection_listener (uint16_t port)
 Constructs a connection listener ("server socket") that listens on the given port of this machine's TCP interface. More...
 
socket accept ()
 Blocks until a remote client makes a connection to this connection listener, then returns a new socket connected to that client. More...
 
std::optional< sockettry_accept (int timeout_ms)
 Waits the specified number of milliseconds for a remote client to connect to this connection listener, then either returns a new socket connected to the client, or nullopt if no client connected before the timeout. More...
 

Private Attributes

std::unique_ptr< int, std::function< void(int *)> > fd
 

Detailed Description

Definition at line 133 of file tcp.hpp.

Constructor & Destructor Documentation

◆ connection_listener()

tcp::connection_listener::connection_listener ( uint16_t  port)
explicit

Constructs a connection listener ("server socket") that listens on the given port of this machine's TCP interface.

Parameters
portThe port to listen on.

Definition at line 210 of file tcp.cpp.

Member Function Documentation

◆ accept()

socket tcp::connection_listener::accept ( )

Blocks until a remote client makes a connection to this connection listener, then returns a new socket connected to that client.

Returns
A socket connected to a remote client.

Definition at line 236 of file tcp.cpp.

◆ try_accept()

std::optional< socket > tcp::connection_listener::try_accept ( int  timeout_ms)

Waits the specified number of milliseconds for a remote client to connect to this connection listener, then either returns a new socket connected to the client, or nullopt if no client connected before the timeout.

Parameters
timeout_msThe time to wait for a new connection
Returns
A socket connected to a remote client, or nullopt if the timeout expired

Definition at line 258 of file tcp.cpp.

Member Data Documentation

◆ fd

std::unique_ptr<int, std::function<void(int*)> > tcp::connection_listener::fd
private

Definition at line 134 of file tcp.hpp.


The documentation for this class was generated from the following files: