Socket Class Reference

Class that manage the connection with the server. More...

#include <socket.h>

List of all members.

Public Member Functions

 Socket ()
 Constructor.
 ~Socket ()
 Destructor.
bool sendStr (string)
 Send a string to the server.
bool closeSock ()
 Close the socket.
bool connectSock (int, string, string)
 Connect the socket to the server.
bool getState ()
 Get connection state.
string getOldestMessage ()
 Get oldest message.

Private Member Functions

string receive ()
 Receive a string from the server.

Private Attributes

bool state
 Socket state.
int mySock
 Socket handle.
string queue
 Buffer that stores messages.


Detailed Description

Class that manage the connection with the server.

This class manage the connection with the irc server. It uses a socket for communication

Definition at line 53 of file socket.h.


Constructor & Destructor Documentation

Socket::Socket (  ) 

Constructor.

Class constructor

Definition at line 34 of file socket.cpp.

References mySock, queue, and state.

Socket::~Socket (  ) 

Destructor.

Clas destructor

Definition at line 44 of file socket.cpp.

References closeSock().


Member Function Documentation

bool Socket::closeSock (  ) 

Close the socket.

Close the socket

Returns:
true if socket well closed, else false

Definition at line 96 of file socket.cpp.

References mySock, and state.

Referenced by receive(), BotKernel::reconnect(), BotKernel::run(), and ~Socket().

bool Socket::connectSock ( int  port,
string  serverName,
string  dedicatedIP 
)

Connect the socket to the server.

Connect the socket to a server The socket can be "block type" and use a dedicated IP adress

Parameters:
port Server port
serverName Server IP or hostname
dedicatedIP Dedicated IP used for connextion. Empty if not used
Returns:
True if connection OK, else false

Definition at line 57 of file socket.cpp.

References mySock, and state.

Referenced by bashfr(), BotKernel::connect(), planet(), tele(), trad(), and wiki().

string Socket::getOldestMessage (  ) 

Get oldest message.

Check queue to get the oldest message. If no message is available, receive() method is called. Then try again to get oldest message. If there is still no message availabe, an empty string is returned.

Returns:
Oldest message, or empty string

Definition at line 123 of file socket.cpp.

References queue, and receive().

Referenced by bashfr(), planet(), BotKernel::run(), tele(), trad(), and wiki().

bool Socket::getState (  ) 

Get connection state.

Get connection state

Returns:
true if the socket is connected, else false

Definition at line 111 of file socket.cpp.

References state.

Referenced by BotKernel::run().

string Socket::receive (  )  [private]

Receive a string from the server.

Receive a string from the server

Returns:
Received string? Empty if nothing received

Definition at line 145 of file socket.cpp.

References closeSock(), mySock, and state.

Referenced by getOldestMessage().

bool Socket::sendStr ( string  strData  ) 

Send a string to the server.

Send a string to the server

Parameters:
strData String to send
Returns:
true if send OK, else false

Definition at line 179 of file socket.cpp.

References mySock.

Referenced by bashfr(), planet(), BotKernel::send(), tele(), trad(), and wiki().


Member Data Documentation

int Socket::mySock [private]

Socket handle.

Definition at line 76 of file socket.h.

Referenced by closeSock(), connectSock(), receive(), sendStr(), and Socket().

string Socket::queue [private]

Buffer that stores messages.

Definition at line 78 of file socket.h.

Referenced by getOldestMessage(), and Socket().

bool Socket::state [private]

Socket state.

Definition at line 74 of file socket.h.

Referenced by closeSock(), connectSock(), getState(), receive(), and Socket().


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

Generated on Sun Apr 19 02:47:38 2009 for trustyRC by  doxygen 1.5.7.1