#include <OldTCPServerSocket.h>
Definition at line 18 of file OldTCPServerSocket.h.
Public Member Functions | |
OldTCPServerSocket () | |
Default constructor, use carefully. | |
OldTCPServerSocket (const int pport, const int m=256) | |
This constructor takes as an argument the port where to listen requests and the size of the backlog. | |
virtual | ~OldTCPServerSocket () |
Destroys the server socket closing connections to every client connected. | |
virtual OldTCPSocket * | accept () |
Waits for a client to connect from a remote host returning it's client socket, please note that this method will wait until a connection is made, so it will block the program or current thread execution. | |
virtual OldTCPSocket * | asyncAccept () |
Waits for a client to connect from a remote host returning it's client socket, however this is an asynchronous call, this means that a call to the method might return NULL or a OldTCPSocket object, if it is NULL it means that nobody has connect to it up to the moment. | |
virtual void | close () |
Closes communication to all clients and shuts down the socket. | |
const int | getPort () |
Returns the port number where the server socket was bounded. | |
void | setPort (int port) |
const int | getSocketID () |
Returns the socket's file descriptor value. | |
int | setSoTimeout (int) |
Defines the timeout before closing connection to the other end of communication. | |
virtual const char * | getClassName () |
Returns the name of the current class. | |
virtual std::string | toString () |
Static Public Member Functions | |
static void | debugmsg (Object *obj, const char *msg, int linenumber=__LINE__, const char *srcfile=__FILE__) |
Will print a debug message to the screen. | |
static void | debugmsgln (Object *obj, const char *msg, int linenumber=__LINE__, const char *srcfile=__FILE__) |
Protected Member Functions | |
int | CreateSocket (const int theport, bool nonblock=false, const int m=256) |
This method binds a server socket to the port specified by theport. | |
int | setSockOption (int opname, void *optval, unsigned int siz) |
Is an interface to setsockopt. | |
int | setTCPOption (int opname, void *optval, unsigned int siz) |
Protected Attributes | |
bool | _created |
* Tells if the server socket has been created or not | |
bool | _nonblock |
This will tell if a call to accept() will block or not. | |
int | maxConn |
Stores the value of the backlog parameter for the listen(2) system call. | |
bool | is_a_copy |
int | tsock |
This file descriptor represents the socket itself as returned by socket(2) and accept(2). | |
struct::sockaddr_in | ipv4addr |
int | port |
Defines the communications port used by the socket or the port which the socket server uses to listen requests. | |
String | string_representation |
For debugging purposes only. | |
std::string | __cls_name |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const Object &s) |
xvr2::Net::OldTCPServerSocket::OldTCPServerSocket | ( | ) |
Default constructor, use carefully.
xvr2::Net::OldTCPServerSocket::OldTCPServerSocket | ( | const int | pport, | |
const int | m = 256 | |||
) |
This constructor takes as an argument the port where to listen requests and the size of the backlog.
virtual xvr2::Net::OldTCPServerSocket::~OldTCPServerSocket | ( | ) | [inline, virtual] |
Destroys the server socket closing connections to every client connected.
Definition at line 44 of file OldTCPServerSocket.h.
References close().
int xvr2::Net::OldTCPServerSocket::CreateSocket | ( | const int | theport, | |
bool | nonblock = false , |
|||
const int | m = 256 | |||
) | [protected] |
This method binds a server socket to the port specified by theport.
virtual OldTCPSocket* xvr2::Net::OldTCPServerSocket::accept | ( | ) | [virtual] |
Waits for a client to connect from a remote host returning it's client socket, please note that this method will wait until a connection is made, so it will block the program or current thread execution.
virtual OldTCPSocket* xvr2::Net::OldTCPServerSocket::asyncAccept | ( | ) | [virtual] |
Waits for a client to connect from a remote host returning it's client socket, however this is an asynchronous call, this means that a call to the method might return NULL or a OldTCPSocket object, if it is NULL it means that nobody has connect to it up to the moment.
The reason for this method is that sometimes you would like to have a loop and do something if nobody connect to the OldTCPServerSocket.
virtual void xvr2::Net::OldTCPServerSocket::close | ( | ) | [virtual] |
const int xvr2::Net::OldTCPServerSocket::getPort | ( | ) | [inline] |
Returns the port number where the server socket was bounded.
Definition at line 68 of file OldTCPServerSocket.h.
References xvr2::Net::OldSocket::port.
void xvr2::Net::OldTCPServerSocket::setPort | ( | int | port | ) | [inline] |
Definition at line 72 of file OldTCPServerSocket.h.
int xvr2::Net::OldSocket::setSockOption | ( | int | opname, | |
void * | optval, | |||
unsigned int | siz | |||
) | [protected, inherited] |
Is an interface to setsockopt.
int xvr2::Net::OldSocket::setTCPOption | ( | int | opname, | |
void * | optval, | |||
unsigned int | siz | |||
) | [protected, inherited] |
const int xvr2::Net::OldSocket::getSocketID | ( | ) | [inherited] |
Returns the socket's file descriptor value.
int xvr2::Net::OldSocket::setSoTimeout | ( | int | ) | [inherited] |
Defines the timeout before closing connection to the other end of communication.
virtual const char* xvr2::Object::getClassName | ( | ) | [virtual, inherited] |
Returns the name of the current class.
static void xvr2::Object::debugmsg | ( | Object * | obj, | |
const char * | msg, | |||
int | linenumber = __LINE__ , |
|||
const char * | srcfile = __FILE__ | |||
) | [static, inherited] |
Will print a debug message to the screen.
static void xvr2::Object::debugmsgln | ( | Object * | obj, | |
const char * | msg, | |||
int | linenumber = __LINE__ , |
|||
const char * | srcfile = __FILE__ | |||
) | [static, inherited] |
virtual std::string xvr2::Object::toString | ( | ) | [virtual, inherited] |
std::ostream& operator<< | ( | std::ostream & | stream, | |
const Object & | s | |||
) | [friend, inherited] |
bool xvr2::Net::OldTCPServerSocket::_created [protected] |
* Tells if the server socket has been created or not
Definition at line 21 of file OldTCPServerSocket.h.
bool xvr2::Net::OldTCPServerSocket::_nonblock [protected] |
This will tell if a call to accept() will block or not.
Definition at line 25 of file OldTCPServerSocket.h.
int xvr2::Net::OldTCPServerSocket::maxConn [protected] |
Stores the value of the backlog parameter for the listen(2) system call.
Definition at line 33 of file OldTCPServerSocket.h.
bool xvr2::Net::OldTCPServerSocket::is_a_copy [protected] |
Definition at line 34 of file OldTCPServerSocket.h.
int xvr2::Net::OldSocket::tsock [protected, inherited] |
This file descriptor represents the socket itself as returned by socket(2) and accept(2).
Definition at line 29 of file OldSocket.h.
struct ::sockaddr_in xvr2::Net::OldSocket::ipv4addr [protected, inherited] |
Definition at line 30 of file OldSocket.h.
int xvr2::Net::OldSocket::port [protected, inherited] |
Defines the communications port used by the socket or the port which the socket server uses to listen requests.
Definition at line 37 of file OldSocket.h.
Referenced by xvr2::Net::OldTCPSocket::getPort(), and getPort().
String xvr2::Net::OldSocket::string_representation [protected, inherited] |
std::string xvr2::Object::__cls_name [protected, inherited] |