Zappy Server
C++ game server: world, rules, scheduler, network
Loading...
Searching...
No Matches
Listener Class Reference

The server's listening socket. More...

#include <Listener.hpp>

+ Collaboration diagram for Listener:

Public Member Functions

 Listener (int port)
 Bind and listen on port.
 
 ~Listener ()
 
int fd () const
 The listening socket fd (to register in poll()).
 
int accept () const
 Accept one pending client; returns its new socket fd.
 
 Listener (const Listener &)=delete
 
Listeneroperator= (const Listener &)=delete
 

Private Attributes

int _fd
 

Detailed Description

The server's listening socket.

Binds and listens on a port in the constructor (throws on failure), closes on destruction. Its fd is polled with the client sockets; when it's readable a new client is waiting and accept() pulls it in. Non-copyable.

Definition at line 31 of file Listener.hpp.

Constructor & Destructor Documentation

◆ Listener() [1/2]

Listener::Listener ( int  port)
explicit

Bind and listen on port.

Exceptions
ListenerExceptionon failure.

Definition at line 11 of file Listener.cpp.

References _fd.

◆ ~Listener()

Listener::~Listener ( )

Definition at line 38 of file Listener.cpp.

References _fd.

◆ Listener() [2/2]

Listener::Listener ( const Listener )
delete

Member Function Documentation

◆ accept()

int Listener::accept ( ) const

Accept one pending client; returns its new socket fd.

Definition at line 45 of file Listener.cpp.

References _fd.

Referenced by ClientManager::_acceptNew().

+ Here is the caller graph for this function:

◆ fd()

int Listener::fd ( ) const

The listening socket fd (to register in poll()).

Definition at line 43 of file Listener.cpp.

References _fd.

Referenced by ClientManager::_rebuildPollFds().

+ Here is the caller graph for this function:

◆ operator=()

Listener & Listener::operator= ( const Listener )
delete

Member Data Documentation

◆ _fd

int Listener::_fd
private

Definition at line 46 of file Listener.hpp.

Referenced by accept(), fd(), Listener(), and ~Listener().


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