Showing
1 changed file
with
14 additions
and
19 deletions
@@ -39,7 +39,7 @@ testHandlerNewMessage(TR_EventHandler this, TR_Event event) | @@ -39,7 +39,7 @@ testHandlerNewMessage(TR_EventHandler this, TR_Event event) | ||
39 | for (i = 0; buf[i]; i++) { | 39 | for (i = 0; buf[i]; i++) { |
40 | if (! isprint(buf[i])) buf[i] = '.'; | 40 | if (! isprint(buf[i])) buf[i] = '.'; |
41 | } | 41 | } |
42 | - printf("echo message: %s(%zd)\n", buf, data->size); | 42 | +// printf("echo message: %s(%zd)\n", buf, data->size); |
43 | 43 | ||
44 | TR_eventHandlerIssueEvent( | 44 | TR_eventHandlerIssueEvent( |
45 | (TR_EventHandler)this, | 45 | (TR_EventHandler)this, |
@@ -130,13 +130,10 @@ main (int argc, char * argv[]) | @@ -130,13 +130,10 @@ main (int argc, char * argv[]) | ||
130 | TR_IoHandler io_handler = TR_new(TR_IoHandler); | 130 | TR_IoHandler io_handler = TR_new(TR_IoHandler); |
131 | TR_ProtocolHandler protocol_handler = TR_new(TR_ProtocolHandler); | 131 | TR_ProtocolHandler protocol_handler = TR_new(TR_ProtocolHandler); |
132 | TestHandler test_handler = TR_new(TestHandler); | 132 | TestHandler test_handler = TR_new(TestHandler); |
133 | -#if 0 | ||
134 | - TR_ConnEntryPoint ep; | ||
135 | - TR_TcpSocket ep_sock; | ||
136 | -#else | ||
137 | - TR_DatagramService ep; | ||
138 | - TR_UdpSocket ep_sock; | ||
139 | -#endif | 133 | + TR_ConnEntryPoint tcp_ep; |
134 | + TR_TcpSocket tcp_ep_sock; | ||
135 | + TR_DatagramService udp_ep; | ||
136 | + TR_UdpSocket udp_ep_sock; | ||
140 | TR_Protocol protocol; | 137 | TR_Protocol protocol; |
141 | 138 | ||
142 | TR_logger = TR_INSTANCE_CAST(TR_Logger, mylogger); | 139 | TR_logger = TR_INSTANCE_CAST(TR_Logger, mylogger); |
@@ -152,17 +149,15 @@ main (int argc, char * argv[]) | @@ -152,17 +149,15 @@ main (int argc, char * argv[]) | ||
152 | (TR_EventHandler)test_handler); | 149 | (TR_EventHandler)test_handler); |
153 | 150 | ||
154 | protocol = TR_new(TR_ProtocolRaw); | 151 | protocol = TR_new(TR_ProtocolRaw); |
155 | -#if 0 | ||
156 | - ep_sock = TR_new(TR_TcpSocket, TR_logger, "0.0.0.0", 5678, 0); | ||
157 | - ep = TR_new(TR_ConnEntryPoint, ep_sock, protocol); | ||
158 | -#else | ||
159 | - ep_sock = TR_new(TR_UdpSocket, TR_logger, "0.0.0.0", 5678, 0); | ||
160 | - TR_socketBind((TR_Socket)ep_sock); | ||
161 | - TR_socketNonblock((TR_Socket)ep_sock); | ||
162 | - ep = TR_new(TR_DatagramService, ep_sock, protocol); | ||
163 | -#endif | ||
164 | - | ||
165 | - TR_commManagerAddEndpoint(cmgr, (TR_CommEndPoint)ep); | 152 | + tcp_ep_sock = TR_new(TR_TcpSocket, TR_logger, "0.0.0.0", 5678, 0); |
153 | + tcp_ep = TR_new(TR_ConnEntryPoint, tcp_ep_sock, protocol); | ||
154 | + udp_ep_sock = TR_new(TR_UdpSocket, TR_logger, "0.0.0.0", 5678, 0); | ||
155 | + TR_socketBind((TR_Socket)udp_ep_sock); | ||
156 | + TR_socketNonblock((TR_Socket)udp_ep_sock); | ||
157 | + udp_ep = TR_new(TR_DatagramService, udp_ep_sock, protocol); | ||
158 | + | ||
159 | + TR_commManagerAddEndpoint(cmgr, (TR_CommEndPoint)tcp_ep); | ||
160 | + TR_commManagerAddEndpoint(cmgr, (TR_CommEndPoint)udp_ep); | ||
166 | 161 | ||
167 | TR_eventDispatcherSetHeartbeat(dispatcher, 1000); | 162 | TR_eventDispatcherSetHeartbeat(dispatcher, 1000); |
168 | TR_eventDispatcherStart(dispatcher); | 163 | TR_eventDispatcherStart(dispatcher); |
Please
register
or
login
to post a comment