MCS  0.3.3-alpha7
mcs::ServerSocket Class Reference

Manage TCP server sockets. More...

#include <mcs.hh>

+ Inheritance diagram for mcs::ServerSocket:

Public Member Functions

bool acceptConnection (int &newsock, unsigned int millisec)
 Wait for an incoming connection. More...
 
void * getSSLContext ()
 
ServerSocketoperator= (const ServerSocket &)
 Declared to avoid using of default assignment operator. More...
 
 ServerSocket (const ServerSocket &)
 Declared to avoid using of default copy constructor. More...
 
 ServerSocket (string interface, unsigned short int port, bool use_ssl=false, string sslcert="", string sslpriv="")
 Constructor. More...
 
 ~ServerSocket ()
 Destructor. More...
 
- Public Member Functions inherited from mcs::NetInterface
unsigned int count ()
 Return how many network interfaces are present in the system. More...
 
unsigned int index ()
 Return the index of the actual interface. More...
 
string ipaddress (int index=-1)
 Return the IP address of an interface. More...
 
string name (int index=-1)
 Return the name of an interface. More...
 
 NetInterface (string name="lo")
 Constructor. More...
 
 NetInterface (const NetInterface &)
 Declared to avoid using of default copy constructor. More...
 
NetInterfaceoperator= (const NetInterface &)
 Declared to avoid using of default assignment operator. More...
 
 ~NetInterface ()
 Destructor. More...
 

Private Attributes

int sockfd
 Server socket descriptor. More...
 
bool use_ssl
 True if the connection should be encrypted. More...
 

Additional Inherited Members

- Protected Member Functions inherited from mcs::NetInterface
int getflags ()
 
bool isup ()
 
int req (int ioctl_num, struct ifreq *ifr)
 
void str_sockaddr (struct sockaddr *sa)
 
void str_sockaddr_in (struct sockaddr_in *sin)
 
- Protected Attributes inherited from mcs::NetInterface
unsigned int lindex
 
vector< string > names
 Vector containing the name of all interfaces present in the system. More...
 

Detailed Description

Manage TCP server sockets.

This class implements a TCP server socket, that is an object that wait for a client connection to arrive, using the acceptConnection() method. When this connection is established the method returns the new socket descriptor.

Definition at line 2015 of file mcs.hh.

Constructor & Destructor Documentation

◆ ServerSocket() [1/2]

mcs::ServerSocket::ServerSocket ( const ServerSocket )

Declared to avoid using of default copy constructor.

Warning
This constructor is declared but not implemented. If you try to use it you will get a compilation error.

◆ ServerSocket() [2/2]

mcs::ServerSocket::ServerSocket ( string  interface,
unsigned short int  port,
bool  use_ssl = false,
string  sslcert = "",
string  sslpriv = "" 
)

Constructor.

This constructor create a server socket using the interface and port specified as arguments.

Parameters
interfaceName of the network interface to be used as server;
portPort on which the server should listen.
Exceptions
FATALMSG_CALLING_BIND;
FATALMSG_CALLING_LISTEN;

Definition at line 799 of file Socket.cc.

◆ ~ServerSocket()

mcs::ServerSocket::~ServerSocket ( )

Destructor.

Definition at line 851 of file Socket.cc.

Member Function Documentation

◆ acceptConnection()

bool mcs::ServerSocket::acceptConnection ( int &  newsock,
unsigned int  millisec 
)

Wait for an incoming connection.

This method will wait until an incoming connection arrives or a timeout occur. When the connection arrives it returns the newly created C socket descriptor through the "newsock" parameter.

Parameters
newsockUpon return will contain the newly created C socket;
millisecTimeout in millisec.
Returns
True if a new connection arrived, false if a timeout occurred.

Definition at line 878 of file Socket.cc.

◆ operator=()

ServerSocket& mcs::ServerSocket::operator= ( const ServerSocket )

Declared to avoid using of default assignment operator.

Warning
This operator is declared but not implemented. If you try to use it you will get a compilation error.

Member Data Documentation

◆ sockfd

int mcs::ServerSocket::sockfd
private

Server socket descriptor.

Definition at line 2019 of file mcs.hh.

◆ use_ssl

bool mcs::ServerSocket::use_ssl
private

True if the connection should be encrypted.

Definition at line 2022 of file mcs.hh.


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

mcslogo

MCS (My Customizable Server) ver. 0.3.3-alpha7
Documentation generated on Mon May 28 07:39:41 UTC 2018