ZeusBase-Library
2.0.4
|
#include <AbstractSocket.h>
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) |
Public Member Functions inherited from zeus::TZObject | |
TZObject () | |
TZObject (const TString &strName) | |
TZObject (const IString &strName) | |
Uint | getHash () const |
TString | toString () const |
virtual TString | getObjName () const |
virtual void | setObjName (const TString &name) |
virtual Retval MQUALIFIER | askForInterface (const InterfaceID &rInterfaceID, IZUnknown *&rpIface) |
virtual void MQUALIFIER | addRef () const |
virtual void MQUALIFIER | release () const |
Protected Member Functions | |
TAbstractSocket () | |
virtual | ~TAbstractSocket () |
virtual void | openSocket ()=0 |
Protected Member Functions inherited from zeus::TZObject | |
virtual | ~TZObject () |
TZObject (const TZObject &rObject) | |
TZObject & | operator= (const TZObject &rObject) |
Int | getRefCounter () const |
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. More... | |
bool | m_bConnected |
Connected flag. More... | |
bool | m_bBlockable |
blockable flag More... | |
bool | m_bReUsable |
reusable flag More... | |
Int | m_iSocketFD |
File descriptor for socket. More... | |
TCriticalSection & | m_rSocketLock |
Critical section to protect socket file descriptor. More... | |
Protected Attributes inherited from zeus::TZObject | |
Uint | m_uiID |
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.
TAbstractSocket::TAbstractSocket | ( | TIPAddress & | rAddress | ) |
Creates an abstract socket
rAddress | : address |
TAbstractSocket::TAbstractSocket | ( | const TString & | rstrAddr, |
Uint | uiPort | ||
) |
Creates an abstract socket
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
iFD | : file descriptor. |
rAddress | : address object |
|
protected |
Creates an abstract socket.
|
protectedvirtual |
Destroys the Socket. On windows platforms this will clean up the win sockets API, if the last socket is destroyed.
|
pure virtual |
Implemented in zeus::TBluetoothSocket, zeus::TBluetoothServerSocket, zeus::TSocket, zeus::TServerSocket, and zeus::TDatagramSocket.
|
virtual |
Disconnects the sockets. This will shutdown the connection first and then close the socket.
TString TAbstractSocket::getAddress | ( | ) | const |
Returns the address of a socket
|
staticprotected |
Returns a socket option as boolean
iFD | : Socket Descripitor |
iOption | : Option to check |
iLevel | : level |
true | : Option set |
false | Option not set |
|
staticprotected |
Checks the error code of the socket and translates it to the Zeus-Error codes
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
|
staticprotected |
Returns a socket option as integer
iFD | : Socket Descripitor |
iOption | : Option to check |
iLevel | : level |
Uint TAbstractSocket::getPort | ( | ) | const |
Returns the port of the socket
|
inline |
Returns the buffer size of the receive buffer
|
inline |
Returns the buffer size of the send buffer
|
inline |
Returns the socket file descripitor
|
inline |
Checks if the socket is blockable
true | : Socket is blockable |
false | : socket is non-blockable |
bool TAbstractSocket::isConnected | ( | ) | const |
Returns the socket status
true | : Socket is connected |
false | : socket is disconnected |
|
inline |
Checks if the socket binding is reusable.
true | : Socket address is reusable |
false | : socket address is not reusable |
bool TAbstractSocket::isValid | ( | ) | const |
Checks if the socket is valid
|
protectedpure virtual |
Implemented in zeus::TBluetoothSocket, zeus::TSocket, zeus::TDatagramSocket, and zeus::TServerSocket.
void TAbstractSocket::setBlockable | ( | bool | bMode | ) |
sets or removes the blockable mode of a socket
|
staticprotected |
Returns a socket option as boolean
iFD | : Socket Descripitor |
iOption | : Option to check |
iLevel | : level |
bValue | : Option value |
|
staticprotected |
Returns a socket option as integer
iFD | : Socket Descripitor |
iOption | : Option to check |
iLevel | : level |
iValue | : Option value |
|
inline |
sets the receive buffer size
iSize | : buffer size |
|
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.
bMode | : mode flag |
|
inline |
sets the sends buffer size
iSize | : buffer size |
|
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
|
protected |
blockable flag
|
protected |
Connected flag.
|
protected |
reusable flag
|
protected |
File descriptor for socket.
|
protected |
Address object.
|
protected |
Critical section to protect socket file descriptor.