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

Client Class Reference

#include <Client.h>

Inheritance diagram for Client:

Inheritance graph
[legend]
Collaboration diagram for Client:

Collaboration graph
[legend]

Public Methods

 Client ()
 Client (Socket *s)
void * run ()
 Very important
You must override this method so you can provide the thread process itself whatever you define this method does in your subclass is what the thread will start doing when you call start()


 ~Client ()
int start ()
 Call this method when you want to start running your thread.

void killMe ()
 This method detaches the thread from the current running program, just like detach() does.

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

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.


Data Fields

bool autodetach
 This variable is just for knowing if the thread can be autodetached or no, currently it does nothing, but is here for backward compatibility.


Protected Methods

int _start ()
 This is a wrapper and is intended to be used only for derived classes.

void detach ()
 This method detaches the thread from the current running program.

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.

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

Client.Client   [inline]
 

Definition at line 12 of file Client.h.

Client::Client Socket *    s
 

Definition at line 11 of file Client.cpp.

Client.~Client   [inline]
 

Definition at line 15 of file Client.h.


Member Function Documentation

int clawsoft.Thread::_start   [protected, inherited]
 

This is a wrapper and is intended to be used only for derived classes.

Definition at line 44 of file Thread.cpp.

References clawsoft.Thread.start(), and clawsoft.Thread.thread.

void clawsoft.Socket::close void    [inherited]
 

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, inherited]
 

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().

void clawsoft.Thread::detach   [protected, inherited]
 

This method detaches the thread from the current running program.

Definition at line 33 of file Thread.cpp.

References clawsoft.Thread.thread.

Referenced by clawsoft.Thread.~Thread().

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.

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, inherited]
 

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.

void clawsoft.Thread::killMe   [inherited]
 

This method detaches the thread from the current running program, just like detach() does.

Definition at line 54 of file Thread.cpp.

References clawsoft.Thread.thread.

Socket & clawsoft.Socket::operator<< String    str [inherited]
 

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 [inherited]
 

Sends a 64bit unsigned quantity to the remote host.

Socket & clawsoft.Socket::operator<< const unsigned long    value [inherited]
 

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 [inherited]
 

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

Socket & clawsoft.Socket::operator<< const long double    value [inherited]
 

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 [inherited]
 

Sends a double presicion value to the remote host.

Definition at line 187 of file Socket.cpp.

Socket & clawsoft.Socket::operator<< const float    value [inherited]
 

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 [inherited]
 

Sends an unsigned integer quantity to the remote host.

Definition at line 177 of file Socket.cpp.

Socket & clawsoft.Socket::operator<< const int    value [inherited]
 

Sends an integer quantity to the remote host.

Definition at line 172 of file Socket.cpp.

Socket & clawsoft.Socket::operator<< const char    chr [inherited]
 

Sends a char to the other host.

Definition at line 167 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> String &    str [inherited]
 

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 [inherited]
 

Receives a 64bit unsigned quantity from the remote host.

Definition at line 327 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> unsigned long &    value [inherited]
 

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

Definition at line 322 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> long &    value [inherited]
 

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

Definition at line 317 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> long double &    value [inherited]
 

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

Definition at line 312 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> double &    value [inherited]
 

Receives a double presicion value from the remote host.

Definition at line 307 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> float &    value [inherited]
 

Receives a floating point value from the remote host.

Definition at line 302 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> unsigned int &    value [inherited]
 

Receives an unsigned integer quantity from the remote host.

Definition at line 297 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> int &    value [inherited]
 

Receives an integer quantity from the remote host.

Definition at line 292 of file Socket.cpp.

Socket & clawsoft.Socket::operator>> char &    chr [inherited]
 

Receives a char from the other host.

Definition at line 287 of file Socket.cpp.

void clawsoft.Socket::read void *    buffer,
unsigned long    size
[inherited]
 

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 * Client::run   [virtual]
 

Very important
You must override this method so you can provide the thread process itself whatever you define this method does in your subclass is what the thread will start doing when you call start()

Implements clawsoft.Thread.

Definition at line 15 of file Client.cpp.

References Protocol.attend(), CLIENT, and counter.

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().

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.

int clawsoft.Thread::start   [inherited]
 

Call this method when you want to start running your thread.

Definition at line 22 of file Thread.cpp.

References clawsoft.Thread.runMethod(), and clawsoft.Thread.thread.

Referenced by clawsoft.Thread._start(), and Server.start().

void clawsoft.Socket::write const void *    buffer,
unsigned long    size
[inherited]
 

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

bool clawsoft.Thread.autodetach [inherited]
 

This variable is just for knowing if the thread can be autodetached or no, currently it does nothing, but is here for backward compatibility.

Definition at line 48 of file Thread.h.

String clawsoft.Socket.host [protected, inherited]
 

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