7 #ifndef _SOCKET_BASE_CLASS_HEADER_
8 #define _SOCKET_BASE_CLASS_HEADER_
tInt64 tTimeStamp
type definition for a time value.
void tVoid
The tVoid is always the definition for the void (non-type).
int tInt
type definition for signed integer value (platform and compiler dependent type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
uint32_t tUInt32
type definition for unsigned integer values (32bit) (platform and compiler independent type).
A common result class usable as return value throughout.
tBool Initialize()
Sets the params for the socket with 0/nullptr.
tShutdownMode
The mode in which to switch the sockets to on shutdown.
static const tUInt32 SOCKET_NO_ADDRESS
Constance for check No Address.
tInt ResolveOptionId(tOptionId id) const
Resolve the option id of the socket.
static tUInt32 AddressToUInt32(const cString &strAddress)
Converts a aaa.bbb.ccc.ddd formated address string to an integer.
tVoid Close(tShutdownMode nHow)
Closes the socket and frees all resources.
static tResult WaitForData(const std::list< cSocket * > &i_lstSockets, cSocket **o_ppSocket, tTimeStamp tmTimeOut=-1)
Blocks the current thread until data are available for reading in at least one of i_lstSockets.
static std::atomic< tInt > m_nSocketLibInitCounter
For internal use only.
tInt SetOption(tInt nLevel, tInt nOptionId, const tVoid *pValue, tInt nValueLen)
Sets a specific option for the socket.
tSocketHandle m_hSocket
this is internal handle of the socket, only use it if you really need that!!
tOptionId
Abstraction of the system specific socket options (e.g.
@ OI_TCP_NODELAY
Equivalent with TCP_NODELAY.
@ OI_SNDBUF
Equivalent with SO_SNDBUF.
@ OI_DONTROUTE
Equivalent with SO_DONTROUTE.
@ OI_REUSEADDR
Equivalent with SO_REUSEADDR.
@ OI_RCVBUF
Equivalent with SO_RCVBUF.
@ OI_KEEPALIVE
Equivalent with SO_KEEPALIVE.
@ OI_LINGER
Equivalent with SO_LINGER.
@ OI_BROADCAST
Equivalent with SO_BROADCAST.
@ OI_DEBUG
Equivalent with SO_DEBUG.
tVoid Close()
Closes the socket and frees all resources.
static cString GetHostName(tUInt32 dwHostAddress=0)
Returns the hostname for a given address.
tBool WaitForData(tTimeStamp nTimeout=-1)
Blocks the current process until data is available for reading.
tOptionLevel
Abstraction of the system specific socket option levels (e.g.
tInt m_nPort
Port of the socket (valid only if opened)
tInt ResolveOptionLevel(tOptionLevel level) const
Resolve the option value of the socket.
static tResult SocketError(tInt nSocketError)
Maps a socket error to an A_UTILS error.
static cString UInt32ToAddress(tUInt32 ui32Address)
Converts an integer to an aaa.bbb.ccc.ddd formated address string.
virtual tBool IsConnected(tTimeStamp nTimeout=0)
Polls the socket for its connection state.
static tInt GetLastErrorCode()
Gets the error code of the last failure.
static tResult FindInterfaceForAddress(tUInt32 ui32FarAddress, tUInt32 &ui32LocalAddress)
If more than one network interface is used in the host the FindInterfaceForAddress finds out the loca...
tResult GetOption(cSocket::tOptionLevel eLevel, cSocket::tOptionId eId, tVoid *o_pValue, tInt *o_pValueLen)
Equivalent with GetOption(tInt, tInt, tVoid*, tInt*).
tResult GetOption(tInt nLevel, tInt nOptionId, tVoid *o_pValue, tInt *o_pValueLen)
gets a specific option for the socket.
tInt SetOption(cSocket::tOptionLevel eLevel, cSocket::tOptionId eId, const tVoid *pValue, tInt nValueLen)
Equivalent to SetOption (tInt, tInt, const tVoid*, tInt) Instead of the system specific constants (e....
static tResult GetLocalAddresses(std::set< tUInt32, std::less< tUInt32 >, std::allocator< tUInt32 > > &oAddresses)
Returns a list of addresses from all local interfaces.
tInt GetPort() const
Retrieves the port of the socket.
static tVoid ReleaseLibraryRef()
to correctly unload the socket-libs you have to call this function
static tVoid AddLibraryRef()
for the work with the static methods you have to use this function to load the nessessary libs,...
virtual ~cSocket()
Default destructor.
tBool SetTimeout(tTimeStamp nReadTimeout=-1, tTimeStamp nWriteTimeout=-1)
Sets timouts fo the read and write socket operations.
tSocketHandle GetHandle() const
Get the internal socket handle.
static tUInt32 GetHostAddress(const cString &strHostName=cString())
Returns the address for a given hostname.
tBool DataAvailable()
Check if data is available for reading (a subsequent read succeed immediately).
cSocket()
Default constructor.
tUInt32 m_ui32Address
Address of the socket (valid only if opened)
tUInt32 GetAddress() const
Retrieves the IP address of the socket.
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
int tSocketHandle
work with platform undependend typedefinitions for socket handlers
bool set(void *dest, std::size_t dest_size, std::uint8_t value, std::size_t bytes_to_set)
Portable safe memset.