URING++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
uringpp::tcp_listener Class Reference

Listen for incoming TCP connections on a socket. More...

#include <uringpp/tcp_listener.h>

Inheritance diagram for uringpp::tcp_listener:
Inheritance graph
[legend]
Collaboration diagram for uringpp::tcp_listener:
Collaboration graph
[legend]

Public Member Functions

int fd () const
 Get the file descriptor of the listener. More...
 
 tcp_listener (tcp_listener &&other) noexcept
 Move construct a new listener object. More...
 
task< std::pair< ip_address, socket > > accept ()
 Accept an incoming connection. More...
 
task< std::pair< ip_address, socket > > accept (std::shared_ptr< event_loop > loop)
 Accept an incoming connection and attach it with the specified loop. More...
 
task< void > close ()
 Close the listener. More...
 
 ~tcp_listener ()
 Destroy the listener object. If the socket is still open, it will be closed. More...
 
- Public Member Functions inherited from uringpp::noncopyable
 noncopyable (noncopyable &&)=default
 
 noncopyable (noncopyable const &)=delete
 
noncopyableoperator= (noncopyable const &)=delete
 
noncopyableoperator= (noncopyable &&)=default
 

Static Public Member Functions

static tcp_listener listen (std::shared_ptr< event_loop > loop, std::string const &hostname, std::string const &port, int backlog=128)
 Listen for incoming TCP connections on the given address. It will create a socket and bind it to the given address. More...
 

Detailed Description

Listen for incoming TCP connections on a socket.

Constructor & Destructor Documentation

◆ tcp_listener()

uringpp::tcp_listener::tcp_listener ( tcp_listener &&  other)
inlinenoexcept

Move construct a new listener object.

Parameters
other

◆ ~tcp_listener()

uringpp::tcp_listener::~tcp_listener ( )
inline

Destroy the listener object. If the socket is still open, it will be closed.

Member Function Documentation

◆ accept() [1/2]

task< std::pair< ip_address, socket > > uringpp::tcp_listener::accept ( )
inline

Accept an incoming connection.

Returns
task<std::pair<ip_address, socket>> A pair of the remote address and the accepted socket

◆ accept() [2/2]

task< std::pair< ip_address, socket > > uringpp::tcp_listener::accept ( std::shared_ptr< event_loop loop)
inline

Accept an incoming connection and attach it with the specified loop.

Returns
task<std::pair<ip_address, socket>> A pair of the remote address and the accepted socket

◆ close()

task< void > uringpp::tcp_listener::close ( )
inline

Close the listener.

Returns
task<void>

◆ fd()

int uringpp::tcp_listener::fd ( ) const
inline

Get the file descriptor of the listener.

Returns
int The file descriptor of the listener.

◆ listen()

static tcp_listener uringpp::tcp_listener::listen ( std::shared_ptr< event_loop loop,
std::string const &  hostname,
std::string const &  port,
int  backlog = 128 
)
inlinestatic

Listen for incoming TCP connections on the given address. It will create a socket and bind it to the given address.

Parameters
loopThe event loop to use.
hostnameThe hostname to listen on.
portThe port to listen on.
Returns
listener The listener object
Examples
helloworld.cc.

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