Kea  1.9.9-git
isc::util::io::SocketSession Class Reference

Socket session object. More...

#include <socketsession.h>

Public Member Functions

 SocketSession (int sock, int family, int type, int protocol, const sockaddr *local_end, const sockaddr *remote_end, const void *data, size_t data_len)
 The constructor. More...
 
const void * getData () const
 Return a pointer to the beginning of the memory region for the session data. More...
 
size_t getDataLength () const
 Return the size of the session data in bytes. More...
 
int getFamily () const
 Return the address family (such as AF_INET6) of the socket. More...
 
const sockaddr & getLocalEndpoint () const
 Return the local end point of the session in the form of sockaddr. More...
 
int getProtocol () const
 Return the transport protocol (such as IPPROTO_UDP) of the socket. More...
 
const sockaddr & getRemoteEndpoint () const
 Return the remote end point of the session in the form of sockaddr. More...
 
int getSocket () const
 Return the socket file descriptor. More...
 
int getType () const
 Return the socket type (such as SOCK_DGRAM) of the socket. More...
 

Detailed Description

Socket session object.

The SocketSession class provides a convenient encapsulation for the notion of a socket session. It's instantiated with straightforward parameters corresponding to a socket session, and provides read only accessors to the parameters to ensure data integrity.

In the initial design and implementation it's only used as a return type of SocketSessionReceiver::pop(), but it could also be used by the SocketSessionForwarder class or for other purposes.

It is assumed that the original owner of a SocketSession object (e.g. a class or a function that constructs it) is responsible for validity of the data passed to the object. See the description of SocketSessionReceiver::pop() for the specific case of that usage.

Definition at line 333 of file socketsession.h.

Constructor & Destructor Documentation

isc::util::io::SocketSession::SocketSession ( int  sock,
int  family,
int  type,
int  protocol,
const sockaddr *  local_end,
const sockaddr *  remote_end,
const void *  data,
size_t  data_len 
)

The constructor.

This is a trivial constructor, taking a straightforward representation of session parameters and storing them internally to ensure integrity.

As long as the given parameters are valid it never throws an exception.

Exceptions
BadValueGiven parameters don't meet the requirement (see the parameter descriptions).
Parameters
sockThe socket file descriptor
familyThe address family (such as AF_INET6) of the socket
typeThe socket type (such as SOCK_DGRAM) of the socket
protocolThe transport protocol (such as IPPROTO_UDP) of the socket.
local_endThe local end point of the session in the form of sockaddr. Must not be NULL.
remote_endThe remote end point of the session in the form of sockaddr. Must not be NULL.
dataA pointer to the beginning of the memory region for the session data. Must not be NULL, and the subsequent data_len bytes must be valid.
data_lenThe size of the session data in bytes. Must not be 0.

Definition at line 257 of file socketsession.cc.

References isc_throw.

Member Function Documentation

const void* isc::util::io::SocketSession::getData ( ) const
inline

Return a pointer to the beginning of the memory region for the session data.

In the current implementation it should never be NULL, and the region of the size returned by getDataLength() is expected to be valid.

Definition at line 385 of file socketsession.h.

size_t isc::util::io::SocketSession::getDataLength ( ) const
inline

Return the size of the session data in bytes.

In the current implementation it should be always larger than 0.

Definition at line 390 of file socketsession.h.

int isc::util::io::SocketSession::getFamily ( ) const
inline

Return the address family (such as AF_INET6) of the socket.

Definition at line 366 of file socketsession.h.

const sockaddr& isc::util::io::SocketSession::getLocalEndpoint ( ) const
inline

Return the local end point of the session in the form of sockaddr.

Definition at line 375 of file socketsession.h.

int isc::util::io::SocketSession::getProtocol ( ) const
inline

Return the transport protocol (such as IPPROTO_UDP) of the socket.

Definition at line 372 of file socketsession.h.

const sockaddr& isc::util::io::SocketSession::getRemoteEndpoint ( ) const
inline

Return the remote end point of the session in the form of sockaddr.

Definition at line 378 of file socketsession.h.

int isc::util::io::SocketSession::getSocket ( ) const
inline

Return the socket file descriptor.

Definition at line 363 of file socketsession.h.

int isc::util::io::SocketSession::getType ( ) const
inline

Return the socket type (such as SOCK_DGRAM) of the socket.

Definition at line 369 of file socketsession.h.


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