#include <AbstractSocket.h>
List of all members.
Public Member Functions |
| | TAbstractSocket (TIPAddress &rAddress) |
| | TAbstractSocket (const TString &rstrAddr, Uint uiPort) |
| | TAbstractSocket (Int iFD, struct sockaddr_in &rAddress) |
| virtual Retval | connect ()=0 |
| virtual Retval | disconnect () |
| TString | getAddress () const |
| TString | getHostName () const |
| Uint | getPort () const |
| Int | getReceiveBufferSize () const |
| Int | getSendBufferSize () const |
| Int | getSocketDescripitor () const |
| bool | isConnected () const |
| bool | isBlockable () const |
| bool | isReUsable () const |
| bool | isValid () const |
| void | setBlockable (bool bMode) |
| void | setReceiveBufferSize (Int iSize) |
| void | setReUsable (bool bMode) |
| void | setSendBufferSize (Int iSize) |
| void | setTCPBufferEnable (bool bMode) |
Protected Member Functions |
| | TAbstractSocket () |
| virtual | ~TAbstractSocket () |
| virtual void | openSocket ()=0 |
Static Protected Member Functions |
| static Retval | getErrorCode (bool bHandleBlockedAsError) |
| static bool | getBoolSocketOption (Int iFD, Int iOption, Int iLevel) |
| static Int | getIntSocketOption (Int iFD, Int iOption, Int iLevel) |
| static void | setBoolSocketOption (Int iFD, Int iOption, Int iLevel, bool bValue) |
| static void | setIntSocketOption (Int iFD, Int iOption, Int iLevel, Int iValue) |
Protected Attributes |
| TIPAddress * | m_pAddress |
| | Address object.
|
| bool | m_bConnected |
| | Connected flag.
|
| bool | m_bBlockable |
| | blockable flag
|
| bool | m_bReUsable |
| | reusable flag
|
| Int | m_iSocketFD |
| | File descriptor for socket.
|
| TCriticalSection & | m_rSocketLock |
| | Critical section to protect socket file descriptor.
|
Detailed Description
This class implements an abstract socket. It defines the correct handling of addresses, socket file descriptors, setting and getting socket options. Note that creating the correct file descriptor must be implemented in the sub classes.
Constructor & Destructor Documentation
| TAbstractSocket::TAbstractSocket |
( |
TIPAddress & |
rAddress ) |
|
Creates an abstract socket
- Parameters:
-
| TAbstractSocket::TAbstractSocket |
( |
const TString & |
rstrAddr, |
|
|
Uint |
uiPort |
|
) |
| |
Creates an abstract socket
- Parameters:
-
| rstrAddr | : address or host name of the server |
| uiPort | : Listening port |
| TAbstractSocket::TAbstractSocket |
( |
Int |
iFD, |
|
|
struct sockaddr_in & |
rAddress |
|
) |
| |
Creates a Socket out of a file descriptor
- Parameters:
-
| iFD | : file descriptor. |
| rAddress | : address object |
| TAbstractSocket::TAbstractSocket |
( |
) |
[protected] |
Creates an abstract socket.
| TAbstractSocket::~TAbstractSocket |
( |
) |
[protected, virtual] |
Destroys the Socket. On windows platforms this will clean up the win sockets API, if the last socket is destroyed.
Member Function Documentation
| virtual Retval zeus::TAbstractSocket::connect |
( |
) |
[pure virtual] |
| Retval TAbstractSocket::disconnect |
( |
) |
[virtual] |
Disconnects the sockets. This will shutdown the connection first and then close the socket.
- Returns:
- RET_NOERROR is always returned
- Note:
- This method can be called from other threads
| TString TAbstractSocket::getAddress |
( |
) |
const |
Returns the address of a socket
- Note:
- This method can be called from other threads
| bool TAbstractSocket::getBoolSocketOption |
( |
Int |
iFD, |
|
|
Int |
iOption, |
|
|
Int |
iLevel |
|
) |
| [static, protected] |
Returns a socket option as boolean
- Parameters:
-
| iFD | : Socket Descripitor |
| iOption | : Option to check |
| iLevel | : level |
- Return values:
-
| true | : Option set |
| false,: | Option not set |
| Retval TAbstractSocket::getErrorCode |
( |
bool |
bHandleBlockedAsError ) |
[static, protected] |
Checks the error code of the socket and translates it to the Zeus-Error codes
- Return values:
-
| RET_NOERROR | : datagram received |
| RET_REQUEST_FAILED | : Data socket not connected |
| RET_INVALID_DATA | : Invalid connection data |
| RET_INVALID_TYPE | : Addresses in the specified family cannot be used with this socket. |
| RET_INVALID_PARAMETER,: | Some of the flags are not supported or invalid |
| RET_NETWORK_ERROR,: | Host unreachable or connection dropped |
| RET_OUTOFMEMORY | : the message is larger than the maximum supported by the underlying transport |
| RET_INTERNAL_ERROR,: | Internal error caused of wrong usage of sockets |
| RET_ABORT | : The blocking call has been interrupted |
| RET_ACCESS_DENIED | : Access to the connection denied |
| TString TAbstractSocket::getHostName |
( |
) |
const |
Returns the hostname of a socket
- Note:
- This method can be called from other threads
| Int TAbstractSocket::getIntSocketOption |
( |
Int |
iFD, |
|
|
Int |
iOption, |
|
|
Int |
iLevel |
|
) |
| [static, protected] |
Returns a socket option as integer
- Parameters:
-
| iFD | : Socket Descripitor |
| iOption | : Option to check |
| iLevel | : level |
- Returns:
- Option value
| Uint TAbstractSocket::getPort |
( |
) |
const |
Returns the port of the socket
- Note:
- This method can be called from other threads
| Int zeus::TAbstractSocket::getReceiveBufferSize |
( |
) |
const [inline] |
Returns the buffer size of the receive buffer
- Returns:
- buffer size
| Int zeus::TAbstractSocket::getSendBufferSize |
( |
) |
const [inline] |
Returns the buffer size of the send buffer
- Returns:
- buffer size
| Int zeus::TAbstractSocket::getSocketDescripitor |
( |
) |
const [inline] |
Returns the socket file descripitor
| bool zeus::TAbstractSocket::isBlockable |
( |
) |
const [inline] |
Checks if the socket is blockable
- Return values:
-
| true | : Socket is blockable |
| false | : socket is non-blockable |
| bool TAbstractSocket::isConnected |
( |
) |
const |
Returns the socket status
- Return values:
-
| true | : Socket is connected |
| false | : socket is disconnected |
- Note:
- This method can be called from other threads
| bool zeus::TAbstractSocket::isReUsable |
( |
) |
const [inline] |
Checks if the socket binding is reusable.
- Return values:
-
| true | : Socket address is reusable |
| false | : socket address is not reusable |
| bool TAbstractSocket::isValid |
( |
) |
const |
Checks if the socket is valid
- Note:
- This method can be called from other threads
| virtual void zeus::TAbstractSocket::openSocket |
( |
) |
[protected, pure virtual] |
| void TAbstractSocket::setBlockable |
( |
bool |
bMode ) |
|
sets or removes the blockable mode of a socket
- Note:
- This method can be called from other threads
| void TAbstractSocket::setBoolSocketOption |
( |
Int |
iFD, |
|
|
Int |
iOption, |
|
|
Int |
iLevel, |
|
|
bool |
bValue |
|
) |
| [static, protected] |
Returns a socket option as boolean
- Parameters:
-
| iFD | : Socket Descripitor |
| iOption | : Option to check |
| iLevel | : level |
| bValue | : Option value |
| void TAbstractSocket::setIntSocketOption |
( |
Int |
iFD, |
|
|
Int |
iOption, |
|
|
Int |
iLevel, |
|
|
Int |
iValue |
|
) |
| [static, protected] |
Returns a socket option as integer
- Parameters:
-
| iFD | : Socket Descripitor |
| iOption | : Option to check |
| iLevel | : level |
| iValue | : Option value |
| void zeus::TAbstractSocket::setReceiveBufferSize |
( |
Int |
iSize ) |
[inline] |
sets the receive buffer size
- Parameters:
-
| void zeus::TAbstractSocket::setReUsable |
( |
bool |
bMode ) |
[inline] |
Call this method to reuse the server connection even if the previous server connection is still waiting for closing. This will avoid problems reconnection to the address:port.
- Parameters:
-
| void zeus::TAbstractSocket::setSendBufferSize |
( |
Int |
iSize ) |
[inline] |
sets the sends buffer size
- Parameters:
-
| void zeus::TAbstractSocket::setTCPBufferEnable |
( |
bool |
bMode ) |
[inline] |
enables or disables the TCP buffer. By default the buffer is enabled. Incase to send the data immediately, the Nagle algorithm must be disabled (=false) by using TCP_NODELAY option
Member Data Documentation
File descriptor for socket.
Critical section to protect socket file descriptor.
The documentation for this class was generated from the following files: