00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _terimber_msg_sock_h_
00029 #define _terimber_msg_sock_h_
00030
00031 #include "aiomsg/msg_conn.h"
00032 #include "aiomsg/msg_lsnr.h"
00033
00034 BEGIN_TERIMBER_NAMESPACE
00035 #pragma pack(4)
00036
00039 class msg_sock_connection : public msg_connection,
00040 public terimber_aiosock_callback
00041 {
00042 protected:
00044 msg_sock_connection(msg_communicator* communicator,
00045 const conf_connection& info
00046 );
00048 msg_sock_connection(msg_communicator* communicator,
00049 size_t handle,
00050 const conf_listener& linfo,
00051 const conf_connection& cinfo
00052 );
00053
00054 public:
00056 virtual ~msg_sock_connection();
00057
00058
00061 static
00062 msg_sock_connection*
00063 connect( msg_communicator* communicator,
00064 const conf_connection& info
00065 );
00068 static
00069 void
00070 accept( size_t handle,
00071 msg_communicator* communicator,
00072 const conf_listener& info,
00073 terimber_aiosock_callback*& callback
00074 );
00075
00076 protected:
00078 virtual
00079 void
00080 v_do_job( size_t ident,
00081 void* user_data
00082 );
00084 virtual
00085 bool
00086 v_has_job( size_t ident,
00087 void* user_data
00088 );
00089
00092 virtual
00093 void
00094 v_on_error( size_t handle,
00095 int err,
00096 aiosock_type mask,
00097 void* userdata
00098 );
00100 virtual
00101 void
00102 v_on_connect( size_t handle,
00103 const sockaddr_in& peeraddr,
00104 void* userdata
00105 );
00106
00107 virtual
00108 void
00109 v_on_send( size_t handle,
00110 void* buf,
00111 size_t requested,
00112 size_t processed,
00113 const sockaddr_in& peeraddr,
00114 void* userdata
00115 );
00117 virtual
00118 void
00119 v_on_receive( size_t handle,
00120 void* buf,
00121 size_t requested,
00122 size_t processed,
00123 const sockaddr_in& peeraddr,
00124 void* userdata
00125 );
00128 virtual
00129 void
00130 v_on_accept( size_t handle,
00131 size_t handle_accepted,
00132 terimber_aiosock_callback*& callback,
00133 const sockaddr_in& peeraddr,
00134 void* userdata
00135 );
00136
00137 protected:
00138 msg_cpp* _msg_send;
00139 ub4_t _offset_send;
00140 msg_cpp* _msg_recv;
00141 ub4_t _size_recv;
00142 ub4_t _offset_recv;
00143 size_t _handle;
00144 };
00145
00149 class msg_sock_listener : public msg_listener,
00150 public terimber_aiosock_callback
00151 {
00152 public:
00154 msg_sock_listener(msg_communicator* communicator,
00155 const conf_listener& info
00156 );
00157
00159 virtual ~msg_sock_listener();
00161 virtual
00162 transport_type
00163 get_type() const
00164 {
00165 return sock;
00166 }
00167
00168 protected:
00171 virtual
00172 void
00173 v_on();
00175 virtual
00176 void
00177 v_off();
00178
00181 virtual
00182 void
00183 v_on_error( size_t handle,
00184 int err,
00185 aiosock_type mask,
00186 void* userdata
00187 );
00189 virtual
00190 void
00191 v_on_connect( size_t handle,
00192 const sockaddr_in& peeraddr,
00193 void* userdata
00194 );
00196 virtual
00197 void
00198 v_on_send( size_t handle,
00199 void* buf,
00200 size_t requested,
00201 size_t processed,
00202 const sockaddr_in& peeraddr,
00203 void* userdata
00204 );
00206 virtual
00207 void
00208 v_on_receive( size_t handle,
00209 void* buf,
00210 size_t requested,
00211 size_t processed,
00212 const sockaddr_in& peeraddr,
00213 void* userdata
00214 );
00217 virtual
00218 void
00219 v_on_accept( size_t handle,
00220 size_t handle_accepted,
00221 terimber_aiosock_callback*& callback,
00222 const sockaddr_in& peeraddr,
00223 void* userdata
00224 );
00225
00226 private:
00227 size_t _handle;
00228 };
00229
00230 #pragma pack()
00231 END_TERIMBER_NAMESPACE
00232
00233 #endif // _terimber_msg_sock_h_
00234