Kea
1.9.9-git
|
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... | |
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.
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.
BadValue | Given parameters don't meet the requirement (see the parameter descriptions). |
sock | The socket file descriptor |
family | The address family (such as AF_INET6) of the socket |
type | The socket type (such as SOCK_DGRAM) of the socket |
protocol | The transport protocol (such as IPPROTO_UDP) of the socket. |
local_end | The local end point of the session in the form of sockaddr . Must not be NULL. |
remote_end | The remote end point of the session in the form of sockaddr . Must not be NULL. |
data | A 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_len | The size of the session data in bytes. Must not be 0. |
Definition at line 257 of file socketsession.cc.
References isc_throw.
|
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.
|
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.
|
inline |
Return the address family (such as AF_INET6) of the socket.
Definition at line 366 of file socketsession.h.
|
inline |
Return the local end point of the session in the form of sockaddr
.
Definition at line 375 of file socketsession.h.
|
inline |
Return the transport protocol (such as IPPROTO_UDP) of the socket.
Definition at line 372 of file socketsession.h.
|
inline |
Return the remote end point of the session in the form of sockaddr
.
Definition at line 378 of file socketsession.h.
|
inline |
Return the socket file descriptor.
Definition at line 363 of file socketsession.h.
|
inline |
Return the socket type (such as SOCK_DGRAM) of the socket.
Definition at line 369 of file socketsession.h.