xvr2::Net::OldTCPSocket Class Reference

#include <OldTCPSocket.h>

Inheritance diagram for xvr2::Net::OldTCPSocket:

Inheritance graph
[legend]

List of all members.


Detailed Description

This class provides all the functionality for working with TCP sockets, from connection to sending a receiving data from a connected peer.

Version:
Revision
531
Deprecated:
This class will be dropped as of xvr2net version 8.0.3 please migrate your code before that, it has only been kept for compatibility with previous releases.

Definition at line 29 of file OldTCPSocket.h.


Public Member Functions

 OldTCPSocket ()
 This is a default constructor that does nothing.
 OldTCPSocket (const String &thehost, int theport)
 This constructor takes as an argument the host location as an IP number or as a name, also the port to connect to, take in count that in the very moment that this class is instantiated the socket would try to connect with the remote host inmediately.
 OldTCPSocket (int s, int pport)
 This constructor tekas as an argument the host location as an IP number or as a name, also the port to connect to, take in count that in the very moment that this class is instantiated the socket would try to connect with the remote host inmediately.
 OldTCPSocket (OldTCPSocket *s)
 Pointer copy-constructor.
 OldTCPSocket (const OldTCPSocket &s)
 This is a copy constructor.
 OldTCPSocket (const IPv4Address *ip, int theport)
 OldTCPSocket (const IPv4Address &ip, int theport)
OldTCPSocketoperator= (const OldTCPSocket &s)
 Use this operator to create copies of an already existent OldTCPSocket.
virtual ~OldTCPSocket ()
 This destructor does nothing.
void close (void)
 Closes the communications channel with the remote host inmmediately.
const int getPort ()
 Returns the port associated with this socket.
void writeLine (const char *str)
 This method will send a null-terminated string of bytes to the other end of communications.
void writeLine (const String &str)
 This method will send a null-terminated string of bytes to the other end of communications.
virtual void write (const void *buffer, unsigned long size)
 Use this method when you need to send a fixed lenght buffer of bytes to the remote host, the routine will cut the buffer in chunks so the transfer can be safelly completed without out of memory error that might be caused if you attempt to send a very big buffer of data.
virtual void readLine (char **str)
 Attempts to read a continuos byte string, it will stop reading data when it finds the 0x00 or
character, in the case we lost connection with the server the string will be fixed to be null-terminated and then the method will throw a BrokenPipeException.
virtual int read (void *buffer, unsigned long size)
 Use this method when you need to receive a fixed lenght buffer of bytes from the remote host, the routine will cut the buffer in chunks so the transfer can be safelly completed without out of memory error that might be caused if you attempt to receive a very big buffer of data.
virtual std::string toString ()
RawInputStreamoutputStream ()
RawOutputStreaminputStream ()
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.

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 IPv4Address *addr, int theport)
 This routine creates the socket by calling socket(2) and resolving the argument thehost to its IP representation in case the address is given as a name, this socket is connected to the port theport.
int CreateSocket (const char *thehost, int 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
char * host
 Stores the hostname where the socket is going to be connected.
RawInputStream out
RawOutputStream in
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)

Constructor & Destructor Documentation

xvr2::Net::OldTCPSocket::OldTCPSocket (  ) 

This is a default constructor that does nothing.

xvr2::Net::OldTCPSocket::OldTCPSocket ( const String thehost,
int  theport 
)

This constructor takes as an argument the host location as an IP number or as a name, also the port to connect to, take in count that in the very moment that this class is instantiated the socket would try to connect with the remote host inmediately.

xvr2::Net::OldTCPSocket::OldTCPSocket ( int  s,
int  pport 
)

This constructor tekas as an argument the host location as an IP number or as a name, also the port to connect to, take in count that in the very moment that this class is instantiated the socket would try to connect with the remote host inmediately.

xvr2::Net::OldTCPSocket::OldTCPSocket ( OldTCPSocket s  ) 

Pointer copy-constructor.

xvr2::Net::OldTCPSocket::OldTCPSocket ( const OldTCPSocket s  ) 

This is a copy constructor.

xvr2::Net::OldTCPSocket::OldTCPSocket ( const IPv4Address ip,
int  theport 
)

xvr2::Net::OldTCPSocket::OldTCPSocket ( const IPv4Address ip,
int  theport 
)

virtual xvr2::Net::OldTCPSocket::~OldTCPSocket (  )  [virtual]

This destructor does nothing.


Member Function Documentation

int xvr2::Net::OldTCPSocket::CreateSocket ( const IPv4Address addr,
int  theport 
) [protected]

This routine creates the socket by calling socket(2) and resolving the argument thehost to its IP representation in case the address is given as a name, this socket is connected to the port theport.

int xvr2::Net::OldTCPSocket::CreateSocket ( const char *  thehost,
int  theport 
) [protected]

OldTCPSocket& xvr2::Net::OldTCPSocket::operator= ( const OldTCPSocket s  ) 

Use this operator to create copies of an already existent OldTCPSocket.

void xvr2::Net::OldTCPSocket::close ( void   ) 

Closes the communications channel with the remote host inmmediately.

const int xvr2::Net::OldTCPSocket::getPort (  )  [inline]

Returns the port associated with this socket.

Definition at line 92 of file OldTCPSocket.h.

References xvr2::Net::OldSocket::port.

void xvr2::Net::OldTCPSocket::writeLine ( const char *  str  ) 

This method will send a null-terminated string of bytes to the other end of communications.

void xvr2::Net::OldTCPSocket::writeLine ( const String str  ) 

This method will send a null-terminated string of bytes to the other end of communications.

virtual void xvr2::Net::OldTCPSocket::write ( const void *  buffer,
unsigned long  size 
) [virtual]

Use this method when you need to send a fixed lenght buffer of bytes to the remote host, the routine will cut the buffer in chunks so the transfer can be safelly completed without out of memory error that might be caused if you attempt to send a very big buffer of data.

virtual void xvr2::Net::OldTCPSocket::readLine ( char **  str  )  [virtual]

Attempts to read a continuos byte string, it will stop reading data when it finds the 0x00 or
character, in the case we lost connection with the server the string will be fixed to be null-terminated and then the method will throw a BrokenPipeException.

This method will attempt to allocate memory to the str pointer so please remember to release the allocated block using Memory::freeBuffer

virtual int xvr2::Net::OldTCPSocket::read ( void *  buffer,
unsigned long  size 
) [virtual]

Use this method when you need to receive a fixed lenght buffer of bytes from the remote host, the routine will cut the buffer in chunks so the transfer can be safelly completed without out of memory error that might be caused if you attempt to receive a very big buffer of data.

virtual std::string xvr2::Net::OldTCPSocket::toString (  )  [virtual]

Reimplemented from xvr2::Object.

RawInputStream& xvr2::Net::OldTCPSocket::outputStream (  ) 

RawOutputStream& xvr2::Net::OldTCPSocket::inputStream (  ) 

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]


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const Object s 
) [friend, inherited]


Member Data Documentation

Definition at line 31 of file OldTCPSocket.h.

char* xvr2::Net::OldTCPSocket::host [protected]

Stores the hostname where the socket is going to be connected.

Definition at line 34 of file OldTCPSocket.h.

Definition at line 45 of file OldTCPSocket.h.

Definition at line 46 of file OldTCPSocket.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 getPort(), and xvr2::Net::OldTCPServerSocket::getPort().

For debugging purposes only.

Definition at line 45 of file OldSocket.h.

std::string xvr2::Object::__cls_name [protected, inherited]

Definition at line 30 of file Object.h.


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

Generated on Fri Jun 20 22:56:02 2008 for X-VR2 SDK by  doxygen 1.5.5