Main Page   Packages   Class Hierarchy   Alphabetical List   Data Structures   File List   Namespace Members   Data Fields   Globals  

clawsoft.Socket Class Reference

#include <Socket.h>

Inheritance diagram for clawsoft.Socket:

Inheritance graph
[legend]
Collaboration diagram for clawsoft.Socket:

Collaboration graph
[legend]

Detailed Description

This is the main interface for client sockets.

Definition at line 22 of file Socket.h.

Public Methods

 Socket ()
 This is a default constructor that does nothing.

 Socket (String const thehost, int theport)
 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 thw remote host inmediately.

 Socket (const char *thehost, int theport)
 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 thw remote host inmediately.

 Socket (int s, int pport)
 This constructor takes as an argument the file descriptor defined for an already opened socket, the main idea is that you can use it in a subclass so you can have the same functionality ypu do when you use the other constructors.

 Socket (const Socket &s)
 This is a copy constructor.

Socket & operator= (Socket s)
 ~Socket ()
 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.

Socket & operator<< (const char chr)
 Sends a char to the other host.

Socket & operator<< (const int value)
 Sends an integer quantity to the remote host.

Socket & operator<< (const unsigned int value)
 Sends an unsigned integer quantity to the remote host.

Socket & operator<< (const float value)
 Sends a floating point value to the remote host.

Socket & operator<< (const double value)
 Sends a double presicion value to the remote host.

Socket & operator<< (const long double value)
 Sends a 96bit floating point value to the remote host.

Socket & operator<< (const long value)
 Sends a long(32bit) quantity to the remote host.

Socket & operator<< (const unsigned long value)
 Sends an unsigned long(32bit) quantity to the remote host.

Socket & operator<< (const unsigned long long value)
 Sends a 64bit unsigned quantity to the remote host.

Socket & operator<< (String str)
 Sends a string to the remote host.

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.

Socket & operator>> (char &chr)
 Receives a char from the other host.

Socket & operator>> (int &value)
 Receives an integer quantity from the remote host.

Socket & operator>> (unsigned int &value)
 Receives an unsigned integer quantity from the remote host.

Socket & operator>> (float &value)
 Receives a floating point value from the remote host.

Socket & operator>> (double &value)
 Receives a double presicion value from the remote host.

Socket & operator>> (long double &value)
 Receives a 96bit floating point value from the remote host.

Socket & operator>> (long &value)
 Receives a long(32bit) quantity from the remote host.

Socket & operator>> (unsigned long &value)
 Receives an unsigned long(32bit) quantity from the remote host.

Socket & operator>> (unsigned long long &value)
 Receives a 64bit unsigned quantity from the remote host.

Socket & operator>> (String &str)
 Receives a string from the remote host.

void 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.

const int getSocket ()
 Returns the socket's file descriptor value.

int setSoTimeout (int)
 Defines the timeout before closing connection to the other end of communication.

char * getClassName ()
 Returns the name of the current class.


Protected Methods

int CreateSocket (const String thehost, 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 setSockOption (int opname, void *optval, unsigned int siz)
 Is an interface to setsockopt.

int setTCPOption (int opname, void *optval, unsigned int siz)
void setClassName (char *n)
 Call this method when you need to set the name of the class you're creating, typically int it's constructor, remeber that you must set the classname for every clas you create, that way you can have more information while being in a debuging process.


Protected Attributes

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

int sock
 This file descriptor represents the socket itself as returned by socket(2) and accept(2).

int port
 Defines the communications port used by the socket or the port which the socket server uses to listen requests.


Constructor & Destructor Documentation

clawsoft.Socket.Socket   [inline]
 

This is a default constructor that does nothing.

Definition at line 34 of file Socket.h.

clawsoft.Socket::Socket String const    thehost,
int    theport
 

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 thw remote host inmediately.

Definition at line 150 of file Socket.cpp.

References clawsoft.Socket.CreateSocket(), and clawsoft.Object.setClassName().

clawsoft.Socket::Socket const char *    thehost,
int    theport
 

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 thw remote host inmediately.

Definition at line 155 of file Socket.cpp.

References clawsoft.Socket.CreateSocket(), and clawsoft.Object.setClassName().

clawsoft.Socket::Socket int    s,
int    pport
 

This constructor takes as an argument the file descriptor defined for an already opened socket, the main idea is that you can use it in a subclass so you can have the same functionality ypu do when you use the other constructors.

Definition at line 143 of file Socket.cpp.

References clawsoft.Socket.host, clawsoft.SocketBase.port, clawsoft.Object.setClassName(), and clawsoft.SocketBase.sock.

clawsoft.Socket::Socket const Socket &    s
 

This is a copy constructor.

Definition at line 138 of file Socket.cpp.

References clawsoft.SocketBase.port, and clawsoft.SocketBase.sock.

clawsoft.Socket.~Socket   [inline]
 

This destructor does nothing.

Definition at line 65 of file Socket.h.


Member Function Documentation

void clawsoft.Socket::close void   
 

Closes the communications channel with the remote host inmmediately.

Definition at line 160 of file Socket.cpp.

References clawsoft.SocketBase.sock.

int clawsoft.Socket::CreateSocket const String    thehost,
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.

Definition at line 79 of file Socket.cpp.

References clawsoft.addSigpipeHandler(), clawsoft.Socket.host, clawsoft.SocketBase.port, clawsoft.SocketBase.sock, and clawsoft.String.toCharPtr().

Referenced by clawsoft.Socket.Socket().

char * clawsoft.Object::getClassName   [inherited]
 

Returns the name of the current class.

Definition at line 18 of file Object.cpp.

References clawsoft.Object.__cls_name.

const int clawsoft.Socket.getPort   [inline]
 

Returns the port associated with this socket.

Definition at line 74 of file Socket.h.

References clawsoft.SocketBase.port.

const int clawsoft.SocketBase.getSocket   [inline, inherited]
 

Returns the socket's file descriptor value.

Definition at line 38 of file SocketBase.h.

References clawsoft.SocketBase.sock.

Socket & clawsoft.Socket::operator<< String    str
 

Sends a string to the remote host.

Definition at line 212 of file Socket.cpp.

References clawsoft.claw_delete_array(), clawsoft.String.size(), clawsoft.String.toCharPtr(), and clawsoft.Socket.write().

Socket& clawsoft.Socket.operator<< const unsigned long long    value
 

Sends a 64bit unsigned quantity to the remote host.

Socket & clawsoft.Socket::operator<< const unsigned long    value
 

Sends an unsigned long(32bit) quantity to the remote host.

Definition at line 202 of file Socket.cpp.

Socket& clawsoft.Socket.operator<< const long    value
 

Sends a long(32bit) quantity to the remote host.

Socket & clawsoft.Socket::operator<< const long double    value
 

Sends a 96bit floating point value to the remote host.

Definition at line 192 of file Socket.cpp.

Socket & clawsoft.Socket::operator<< const double    value
 

Sends a double presicion value to the remote host.

Definition at line 187 of file Socket.cpp.

Socket & clawsoft.Socket::operator<< const float    value
 

Sends a floating point value to the remote host.

Definition at line 182 of file Socket.cpp.

Socket & clawsoft.Socket::operator<< const unsigned int    value
 

Sends an unsigned integer quantity to the remote host.

Definition at line 177 of file Socket.cpp.

Socket & clawsoft.Socket::operator<< const int    value
 

Sends an integer quantity to the remote host.

Definition at line 172 of file Socket.cpp.

Socket & clawsoft.Socket::operator<< const char    chr
 

Sends a char to the other host.

Definition at line 167 of file Socket.cpp.

Socket& clawsoft.Socket.operator= Socket    s [inline]
 

Definition at line 58 of file Socket.h.

References clawsoft.SocketBase.port, and clawsoft.SocketBase.sock.

Socket & clawsoft.Socket::operator>> String   str
 

Receives a string from the remote host.

Definition at line 332 of file Socket.cpp.

References clawsoft.Socket.read(), READ_TIMEOUT, and clawsoft.SocketBase.sock.

Socket & clawsoft.Socket::operator>> unsigned long long &    value
 

Receives a 64bit unsigned quantity from the remote host.

Definition at line 327 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> unsigned long &    value
 

Receives an unsigned long(32bit) quantity from the remote host.

Definition at line 322 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> long &    value
 

Receives a long(32bit) quantity from the remote host.

Definition at line 317 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> long double &    value
 

Receives a 96bit floating point value from the remote host.

Definition at line 312 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> double &    value
 

Receives a double presicion value from the remote host.

Definition at line 307 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> float &    value
 

Receives a floating point value from the remote host.

Definition at line 302 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> unsigned int &    value
 

Receives an unsigned integer quantity from the remote host.

Definition at line 297 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> int &    value
 

Receives an integer quantity from the remote host.

Definition at line 292 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> char &    chr
 

Receives a char from the other host.

Definition at line 287 of file Socket.cpp.

void clawsoft.Socket::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.

Definition at line 358 of file Socket.cpp.

References READ_TIMEOUT, clawsoft.SocketBase.sock, and SOCK_CHUNK_SIZE.

Referenced by clawsoft.Socket.operator>>().

void clawsoft.Object::setClassName char *    n [protected, inherited]
 

Call this method when you need to set the name of the class you're creating, typically int it's constructor, remeber that you must set the classname for every clas you create, that way you can have more information while being in a debuging process.

Definition at line 14 of file Object.cpp.

References clawsoft.Object.__cls_name.

Referenced by clawsoft.ArrayOutOfBoundsException.ArrayOutOfBoundsException(), clawsoft.BrokenPipeException.BrokenPipeException(), clawsoft.Dialog.CancelButton.CancelButton(), clawsoft.CantLoadDSOException.CantLoadDSOException(), clawsoft.CantUnloadDSOException.CantUnloadDSOException(), clawsoft.ConnectionRefusedException.ConnectionRefusedException(), clawsoft.ConnectionTimeoutException.ConnectionTimeoutException(), clawsoft.Dialog.Dialog(), clawsoft.DSOException.DSOException(), clawsoft.DSOSymbolException.DSOSymbolException(), clawsoft.ElementNotFoundException.ElementNotFoundException(), clawsoft.Font.Font(), clawsoft.GameSelector.GameSelector(), clawsoft.Dialog.HelpButton.HelpButton(), clawsoft.IOException.IOException(), clawsoft.KeyboardEvent.KeyboardEvent(), clawsoft.LoginDialog.LoginDialog(), clawsoft.Mutex.Mutex(), clawsoft.MutexException.MutexException(), clawsoft.NetworkException.NetworkException(), clawsoft.NetworkUnreachableException.NetworkUnreachableException(), clawsoft.NoMoreTokensException.NoMoreTokensException(), clawsoft.NullPointerException.NullPointerException(), clawsoft.NumberException.NumberException(), clawsoft.Object.Object(), clawsoft.Dialog.OKButton.OKButton(), clawsoft.Plugin.Plugin(), clawsoft.ProcOutOfFileDescriptorsException.ProcOutOfFileDescriptorsException(), Random.Random(), clawsoft.ServerSocket.ServerSocket(), clawsoft.Socket.Socket(), clawsoft.SocketAlreadyBoundedException.SocketAlreadyBoundedException(), clawsoft.SocketAlreadyUsedException.SocketAlreadyUsedException(), clawsoft.SocketUnableToReadException.SocketUnableToReadException(), clawsoft.SocketUnableToWriteException.SocketUnableToWriteException(), clawsoft.SysOutOfFileDescriptorsException.SysOutOfFileDescriptorsException(), clawsoft.TextBox.TextBox(), clawsoft.TextButton.TextButton(), clawsoft.TextField.TextField(), clawsoft.Thread.Thread(), clawsoft.UnableToLockMutexException.UnableToLockMutexException(), clawsoft.UnableToUnlockMutexException.UnableToUnlockMutexException(), and clawsoft.Window.Window().

int clawsoft.SocketBase::setSockOption int    opname,
void *    optval,
unsigned int    siz
[protected, inherited]
 

Is an interface to setsockopt.

Definition at line 13 of file SocketBase.cpp.

References clawsoft.SocketBase.sock.

Referenced by clawsoft.SocketBase.setSoTimeout().

int clawsoft.SocketBase::setSoTimeout int    [inherited]
 

Defines the timeout before closing connection to the other end of communication.

Definition at line 28 of file SocketBase.cpp.

References clawsoft.SocketBase.setSockOption().

int clawsoft.SocketBase::setTCPOption int    opname,
void *    optval,
unsigned int    siz
[protected, inherited]
 

Definition at line 23 of file SocketBase.cpp.

void clawsoft.Socket::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.

Definition at line 229 of file Socket.cpp.

References clawsoft.SocketBase.sock, and SOCK_CHUNK_SIZE.

Referenced by clawsoft.Socket.operator<<().


Field Documentation

String clawsoft.Socket.host [protected]
 

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

Definition at line 25 of file Socket.h.

Referenced by clawsoft.Socket.CreateSocket(), and clawsoft.Socket.Socket().

int clawsoft.SocketBase.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 27 of file SocketBase.h.

Referenced by clawsoft.ServerSocket.accept(), clawsoft.Socket.CreateSocket(), clawsoft.ServerSocket.CreateSocket(), clawsoft.Socket.getPort(), clawsoft.ServerSocket.getPort(), clawsoft.Socket.operator=(), and clawsoft.Socket.Socket().

int clawsoft.SocketBase.sock [protected, inherited]
 

This file descriptor represents the socket itself as returned by socket(2) and accept(2).

Definition at line 22 of file SocketBase.h.

Referenced by clawsoft.ServerSocket.accept(), clawsoft.Socket.close(), clawsoft.ServerSocket.close(), clawsoft.Socket.CreateSocket(), clawsoft.ServerSocket.CreateSocket(), clawsoft.SocketBase.getSocket(), clawsoft.Socket.operator=(), clawsoft.Socket.operator>>(), clawsoft.Socket.read(), clawsoft.SocketBase.setSockOption(), clawsoft.Socket.Socket(), and clawsoft.Socket.write().


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

Powered by:

SourceForge Logo