|
|
@ -39,7 +39,7 @@ testHandlerNewMessage(TR_EventHandler this, TR_Event event) |
|
|
for (i = 0; buf[i]; i++) { |
|
|
for (i = 0; buf[i]; i++) { |
|
|
if (! isprint(buf[i])) buf[i] = '.'; |
|
|
if (! isprint(buf[i])) buf[i] = '.'; |
|
|
} |
|
|
} |
|
|
printf("echo message: %s(%zd)\n", buf, data->size); |
|
|
|
|
|
|
|
|
// printf("echo message: %s(%zd)\n", buf, data->size); |
|
|
|
|
|
|
|
|
TR_eventHandlerIssueEvent( |
|
|
TR_eventHandlerIssueEvent( |
|
|
(TR_EventHandler)this, |
|
|
(TR_EventHandler)this, |
|
|
@ -130,13 +130,10 @@ main (int argc, char * argv[]) |
|
|
TR_IoHandler io_handler = TR_new(TR_IoHandler); |
|
|
TR_IoHandler io_handler = TR_new(TR_IoHandler); |
|
|
TR_ProtocolHandler protocol_handler = TR_new(TR_ProtocolHandler); |
|
|
TR_ProtocolHandler protocol_handler = TR_new(TR_ProtocolHandler); |
|
|
TestHandler test_handler = TR_new(TestHandler); |
|
|
TestHandler test_handler = TR_new(TestHandler); |
|
|
#if 0 |
|
|
|
|
|
TR_ConnEntryPoint ep; |
|
|
|
|
|
TR_TcpSocket ep_sock; |
|
|
|
|
|
#else |
|
|
|
|
|
TR_DatagramService ep; |
|
|
|
|
|
TR_UdpSocket ep_sock; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
TR_ConnEntryPoint tcp_ep; |
|
|
|
|
|
TR_TcpSocket tcp_ep_sock; |
|
|
|
|
|
TR_DatagramService udp_ep; |
|
|
|
|
|
TR_UdpSocket udp_ep_sock; |
|
|
TR_Protocol protocol; |
|
|
TR_Protocol protocol; |
|
|
|
|
|
|
|
|
TR_logger = TR_INSTANCE_CAST(TR_Logger, mylogger); |
|
|
TR_logger = TR_INSTANCE_CAST(TR_Logger, mylogger); |
|
|
@ -152,17 +149,15 @@ main (int argc, char * argv[]) |
|
|
(TR_EventHandler)test_handler); |
|
|
(TR_EventHandler)test_handler); |
|
|
|
|
|
|
|
|
protocol = TR_new(TR_ProtocolRaw); |
|
|
protocol = TR_new(TR_ProtocolRaw); |
|
|
#if 0 |
|
|
|
|
|
ep_sock = TR_new(TR_TcpSocket, TR_logger, "0.0.0.0", 5678, 0); |
|
|
|
|
|
ep = TR_new(TR_ConnEntryPoint, ep_sock, protocol); |
|
|
|
|
|
#else |
|
|
|
|
|
ep_sock = TR_new(TR_UdpSocket, TR_logger, "0.0.0.0", 5678, 0); |
|
|
|
|
|
TR_socketBind((TR_Socket)ep_sock); |
|
|
|
|
|
TR_socketNonblock((TR_Socket)ep_sock); |
|
|
|
|
|
ep = TR_new(TR_DatagramService, ep_sock, protocol); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
TR_commManagerAddEndpoint(cmgr, (TR_CommEndPoint)ep); |
|
|
|
|
|
|
|
|
tcp_ep_sock = TR_new(TR_TcpSocket, TR_logger, "0.0.0.0", 5678, 0); |
|
|
|
|
|
tcp_ep = TR_new(TR_ConnEntryPoint, tcp_ep_sock, protocol); |
|
|
|
|
|
udp_ep_sock = TR_new(TR_UdpSocket, TR_logger, "0.0.0.0", 5678, 0); |
|
|
|
|
|
TR_socketBind((TR_Socket)udp_ep_sock); |
|
|
|
|
|
TR_socketNonblock((TR_Socket)udp_ep_sock); |
|
|
|
|
|
udp_ep = TR_new(TR_DatagramService, udp_ep_sock, protocol); |
|
|
|
|
|
|
|
|
|
|
|
TR_commManagerAddEndpoint(cmgr, (TR_CommEndPoint)tcp_ep); |
|
|
|
|
|
TR_commManagerAddEndpoint(cmgr, (TR_CommEndPoint)udp_ep); |
|
|
|
|
|
|
|
|
TR_eventDispatcherSetHeartbeat(dispatcher, 1000); |
|
|
TR_eventDispatcherSetHeartbeat(dispatcher, 1000); |
|
|
TR_eventDispatcherStart(dispatcher); |
|
|
TR_eventDispatcherStart(dispatcher); |
|
|
|