Home / Open source / Terimber 2.0
msg_sock_connection Class Referenceclass implements the Socket connection
More...
#include <msg_sock.h>
List of all members.
|
Public Member Functions |
virtual | ~msg_sock_connection () |
| destructor
|
Static Public Member Functions |
static msg_sock_connection * | connect (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
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
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().
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().
void msg_sock_connection::v_do_job |
( |
size_t |
ident, |
|
|
void * |
user_data | |
|
) |
| | [protected, virtual] |
overrides the base functionality
- Parameters:
-
ident |
thread ident |
user_data |
user defined data |
Implements terimber_thread_employer.
Definition at line 297 of file msg_sock.cpp.
References msg_base::_communicator, _handle, msg_connection::_info, _msg_send, conf_connection::_session, msg_cpp::_sessionid, msg_cpp::_type, msg_communicator::comm_msg(), smart_pointer< C >::detach(), en_log_info, terimber_log::format_logging(), msg_communicator::get_aiosock(), msg_cpp::get_block(), msg_connection::get_crypt_key(), handshake_type, msg_pack::make_error_msg(), msg_pack::make_reply_msg(), msg_cpp::pack_msg(), msg_queue< 3 >::pop(), queue_thread_ident, aiosock::send(), msg_connection::set_last_activity(), msg_communicator::shutdown_connection(), sockStatus(), msg_t::timeout, user_type_mask, user_type_send, user_type_send_async, and exception::what().
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] |
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
The documentation for this class was generated from the following files:
|
|