29 #ifndef Pt_Net_TcpServer_h
30 #define Pt_Net_TcpServer_h
32 #include <Pt/Net/Api.h>
33 #include <Pt/System/Selectable.h>
34 #include <Pt/Signal.h>
67 {
return _deferAccept; }
84 { _backlog = backlog; }
140 {
return _connectionPending; }
148 const TcpServerImpl& impl()
const
152 TcpServerImpl& impl()
170 TcpServerImpl* _impl;
178 #endif // Pt_Net_TcpServer_h
virtual void onCancel()
Blocks until operation has cancelled.
Core module.
Definition: pt-gfx-images.dox:14
virtual bool onRun()
Check if ready and run.
virtual void onAttach(System::EventLoop &loop)
Attached to loop.
TcpServerOptions(int backlog=5)
Construct with accept backlog size.
TcpServer(const Endpoint &ep)
Creates a server socket and listens on an address.
TCP server socket.
Definition: TcpServer.h:100
TcpServer(System::EventLoop &loop)
Construct with event loop.
Multicast Signal to call multiple slots.
Definition: Signal.h:110
int backlog() const
Returns the accept backlog size.
Definition: TcpServer.h:78
TcpServer()
Default Constructor.
System::EventLoop * loop() const
Returns the parent event loop.
Definition: TcpServer.h:144
TcpServerOptions & operator=(const TcpServerOptions &opts)
Assignment operator.
TcpServerOptions(const TcpServerOptions &opts)
Copy constructor.
void setDeferAccept(int n)
Defer accept until data arrives.
Definition: TcpServer.h:73
void close()
Close the server and stop listening and accepting.
int acceptDeferred() const
Returns the max time for data to arrive.
Definition: TcpServer.h:66
TCP server options.
Definition: TcpServer.h:44
Represents a Network Host.
Definition: Endpoint.h:47
~TcpServerOptions()
Destructor.
Dispatches operations through an event loop.
Definition: Selectable.h:45
virtual void onDetach(System::EventLoop &loop)
Detached from loop.
void beginAccept()
Begin accepting a connection.
Thread-safe event loop supporting I/O multiplexing and Timers.
Definition: EventLoop.h:74
void listen(const Endpoint &ep, const TcpServerOptions &options)
Listen at local endpoint.
Signal< TcpServer & > & connectionPending()
Notifies that a connection was accepted.
Definition: TcpServer.h:139
void listen(const Endpoint &ep)
Listen at local endpoint.
uint_type uint32_t
Unsigned 32-bit integer type.
Definition: Types.h:42
void setBacklog(int backlog)
Sets the accept backlog size.
Definition: TcpServer.h:83