Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

msg_sock_connection Class Reference

class implements the Socket connection More...

#include <msg_sock.h>

Inheritance diagram for msg_sock_connection:

msg_connection terimber_aiosock_callback msg_queue_processor msg_base msg_queue< 3 > terimber_thread_employer

List of all members.

Public Member Functions

virtual ~msg_sock_connection ()
 destructor

Static Public Member Functions

static msg_sock_connectionconnect (msg_communicator *communicator, const conf_connection &info)
 constructor for initiator establishes the new connection to the peer
static void accept (size_t handle, msg_communicator *communicator, const conf_listener &info, terimber_aiosock_callback *&callback)
 constructor for receiver handshake process with the peer

Protected Member Functions

 msg_sock_connection (msg_communicator *communicator, const conf_connection &info)
 constructor for initiator
 msg_sock_connection (msg_communicator *communicator, size_t handle, const conf_listener &linfo, const conf_connection &cinfo)
 constructor for receiver
virtual void v_do_job (size_t ident, void *user_data)
 overrides the base functionality
virtual bool v_has_job (size_t ident, void *user_data)
 thread callback
virtual void v_on_error (size_t handle, int err, aiosock_type mask, void *userdata)
 aio callbacks port will call function after error occured
virtual void v_on_connect (size_t handle, const sockaddr_in &peeraddr, void *userdata)
 port will call function after successfully connecting to socket
virtual void v_on_send (size_t handle, void *buf, size_t requested, size_t processed, const sockaddr_in &peeraddr, void *userdata)
 port will call function after successfully sending buffer to socket
virtual void v_on_receive (size_t handle, void *buf, size_t requested, size_t processed, const sockaddr_in &peeraddr, void *userdata)
 port will call function after successfully receiving buffer from socket
virtual void v_on_accept (size_t handle, size_t handle_accepted, terimber_aiosock_callback *&callback, const sockaddr_in &peeraddr, void *userdata)
 port will call function after successfully accepting the new incoming connection user can change the callback, by default it's an object which created a listener

Protected Attributes

msg_cpp_msg_send
 messages buffer for send processes
ub4_t _offset_send
 offset of sent message buffer
msg_cpp_msg_recv
 messages buffer for receive processes
ub4_t _size_recv
 size of message should be received
ub4_t _offset_recv
 offset of received message buffer
size_t _handle
 socket handle


Detailed Description

class implements the Socket connection

Definition at line 39 of file msg_sock.h.


Constructor & Destructor Documentation

msg_sock_connection::msg_sock_connection ( msg_communicator communicator,
const conf_connection info 
) [protected]

constructor for initiator

Parameters:
communicator  communicator pointer
info  connection info

Definition at line 67 of file msg_sock.cpp.

References msg_base::_communicator, _handle, aiosock::create(), and msg_communicator::get_aiosock().

Referenced by accept(), and connect().

msg_sock_connection::msg_sock_connection ( msg_communicator communicator,
size_t  handle,
const conf_listener linfo,
const conf_connection cinfo 
) [protected]

constructor for receiver

Parameters:
communicator  communicator pointer
handle  socket handle
linfo  listener info
cinfo  connection info

Definition at line 78 of file msg_sock.cpp.

References _handle.

msg_sock_connection::~msg_sock_connection (  )  [virtual]


Member Function Documentation

msg_sock_connection * msg_sock_connection::connect ( msg_communicator communicator,
const conf_connection info 
) [static]

constructor for initiator establishes the new connection to the peer

Parameters:
communicator  communicator pointer
info  connection info

Definition at line 369 of file msg_sock.cpp.

References _handle, conf_connection::_network, conf_connection::_port, exception::_throw(), msg_communicator::add_connection(), aiosock::connect(), msg_communicator::get_aiosock(), MSG_RESULT_NOTMEMORY, msg_sock_connection(), msgMsgTable, and sockStatus().

Referenced by msg_communicator::_connect().

void msg_sock_connection::accept ( size_t  handle,
msg_communicator communicator,
const conf_listener info,
terimber_aiosock_callback *&  callback 
) [static]

constructor for receiver handshake process with the peer

Parameters:
handle  socket handle
communicator  communicator pointer
info  listener info
callback  aiosock callback

Definition at line 412 of file msg_sock.cpp.

References conf_connection::_address, _handle, _size_recv, exception::_throw(), msg_communicator::add_connection(), aiosock::close(), msg_communicator::get_aiosock(), MSG_RESULT_NOTMEMORY, msg_sock_connection(), msgMsgTable, aiosock::receive(), sockStatus(), uuid_gen(), and msg_queue_processor::v_on().

Referenced by msg_sock_listener::v_on_accept().

bool msg_sock_connection::v_has_job ( size_t  ident,
void *  user_data 
) [protected, virtual]

void msg_sock_connection::v_on_error ( size_t  handle,
int  err,
aiosock_type  mask,
void *  userdata 
) [protected, virtual]

aio callbacks port will call function after error occured

Parameters:
handle  socket handle
err  error code
mask  reason
userdata  user defined data

Implements terimber_aiosock_callback.

Definition at line 115 of file msg_sock.cpp.

References msg_base::_communicator, _handle, en_log_info, terimber_log::format_logging(), and msg_communicator::shutdown_connection().

void msg_sock_connection::v_on_connect ( size_t  handle,
const sockaddr_in &  peeraddr,
void *  userdata 
) [protected, virtual]

port will call function after successfully connecting to socket

Parameters:
handle  socket handle
peeraddr  peer address
userdata  user defined data

Implements terimber_aiosock_callback.

Definition at line 126 of file msg_sock.cpp.

References msg_base::_communicator, _handle, _size_recv, smart_pointer< C >::detach(), en_log_info, terimber_log::format_logging(), msg_communicator::get_aiosock(), msg_connection::prepare_handshake_msg(), msg_queue< 3 >::push(), aiosock::receive(), msg_communicator::shutdown_connection(), sockStatus(), and exception::what().

void msg_sock_connection::v_on_send ( size_t  handle,
void *  buf,
size_t  requested,
size_t  processed,
const sockaddr_in &  peeraddr,
void *  userdata 
) [protected, virtual]

port will call function after successfully sending buffer to socket

Parameters:
handle  socket handle
buf  buffer
requested  requested bytes to send
processed  actually processed bytes
peeraddr  peer address
userdata  user defined data

Implements terimber_aiosock_callback.

Definition at line 153 of file msg_sock.cpp.

References msg_base::_communicator, _handle, _msg_send, _offset_send, msg_communicator::destroy_msg(), en_log_info, terimber_log::format_logging(), msg_communicator::get_aiosock(), msg_cpp::get_block(), aiosock::send(), msg_communicator::shutdown_connection(), sockStatus(), msg_t::timeout, and msg_connection::wakeup().

void msg_sock_connection::v_on_receive ( size_t  handle,
void *  buf,
size_t  requested,
size_t  processed,
const sockaddr_in &  peeraddr,
void *  userdata 
) [protected, virtual]

port will call function after successfully receiving buffer from socket

Parameters:
handle  socket handle
buf  buffer
requested  requested bytes to receive
processed  actually processed bytes
peeraddr  peer address
userdata  user defined data

Implements terimber_aiosock_callback.

Definition at line 187 of file msg_sock.cpp.

References msg_base::_communicator, _handle, _msg_recv, _offset_recv, _size_recv, exception::_throw(), msg_cpp::block_size(), msg_communicator::construct_msg(), en_log_info, terimber_log::format_logging(), msg_communicator::get_aiosock(), msg_cpp::get_block(), msg_connection::get_crypt_key(), msg_default_timeout, MSG_RESULT_INVALID_MSGFORMAT, msgMsgTable, msg_connection::process_incoming_message(), aiosock::receive(), msg_communicator::shutdown_connection(), sockStatus(), msg_cpp::unpack_msg(), and exception::what().

void msg_sock_connection::v_on_accept ( size_t  handle,
size_t  handle_accepted,
terimber_aiosock_callback *&  callback,
const sockaddr_in &  peeraddr,
void *  userdata 
) [protected, virtual]

port will call function after successfully accepting the new incoming connection user can change the callback, by default it's an object which created a listener

Parameters:
handle  listener handle
handle_accepted  accepted socket handle
callback  aiosock callback
peeraddr  peer address
userdata  user defined data

Implements terimber_aiosock_callback.

Definition at line 264 of file msg_sock.cpp.


Member Data Documentation

messages buffer for send processes

Definition at line 138 of file msg_sock.h.

Referenced by v_do_job(), v_has_job(), v_on_send(), and ~msg_sock_connection().

offset of sent message buffer

Definition at line 139 of file msg_sock.h.

Referenced by v_on_send().

messages buffer for receive processes

Definition at line 140 of file msg_sock.h.

Referenced by v_on_receive(), and ~msg_sock_connection().

size of message should be received

Definition at line 141 of file msg_sock.h.

Referenced by accept(), v_on_connect(), v_on_receive(), and ~msg_sock_connection().

offset of received message buffer

Definition at line 142 of file msg_sock.h.

Referenced by v_on_receive().


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


© Copyright Terimber 2003-.