TcpServer Class Reference

#include <Pt/Net/TcpServer.h>

TCP server socket.

Inherits Selectable.

Public Member Functions

 TcpServer ()
 Default Constructor.
 
 TcpServer (System::EventLoop &loop)
 Construct with event loop.
 
 TcpServer (const Endpoint &ep)
 Creates a server socket and listens on an address.
 
 ~TcpServer ()
 Destructor.
 
void listen (const Endpoint &ep)
 Listen at local endpoint.
 
void listen (const Endpoint &ep, const TcpServerOptions &options)
 Listen at local endpoint.
 
void beginAccept ()
 Begin accepting a connection.
 
void close ()
 Close the server and stop listening and accepting.
 
Signal< TcpServer & > & connectionPending ()
 Notifies that a connection was accepted. More...
 
System::EventLooploop () const
 Returns the parent event loop.
 
void setActive (EventLoop &parent)
 Sets the parent loop, so that operations can be run.
 
void detach ()
 Remove from event loop and cancels outstanding operations.
 
void cancel ()
 Cancels all operations.
 
bool run ()
 Run operation if it is ready.
 
EventLoop * parent () const
 Returns the used event loop.
 

Protected Member Functions

virtual void onAttach (System::EventLoop &loop)
 Attached to loop.
 
virtual void onDetach (System::EventLoop &loop)
 Detached from loop.
 
virtual void onCancel ()
 Blocks until operation has cancelled.
 
virtual bool onRun ()
 Check if ready and run.
 
void post ()
 Posts this selectable to its event loop from any thread.
 

Member Function Documentation

◆ connectionPending()

Signal<TcpServer&>& connectionPending ( )

This signal is send when the TcpServer is monitored in an EventLoop and a connection was accepted.