2 changed files with 2 additions and 79 deletions
@ -1,9 +1,8 @@ |
|||
#!/bin/bash |
|||
#TRLIBS="-ltrbase -ltrhashing -ltrio -ltrdata -ltrevent -ltrcomm" |
|||
TRLIBS="/usr/local/lib/libtrcomm.a /usr/local/lib/libtrevent.a /usr/local/lib/libtrdata.a /usr/local/lib/libtrio.a /usr/local/lib/libtrhashing.a /usr/local/lib/libtrbase.a" |
|||
TRLIBS="-ltrbase -ltrhashing -ltrio -ltrdata -ltrevent -ltrcomm" |
|||
#TRLIBS="/usr/local/lib/libtrcomm.a /usr/local/lib/libtrevent.a /usr/local/lib/libtrdata.a /usr/local/lib/libtrio.a /usr/local/lib/libtrhashing.a /usr/local/lib/libtrbase.a" |
|||
LIBS="-lcrypto -lssl -lrt -luuid" |
|||
gcc ${CFLAGS} -std=c99 -c -o test_handler.o test_handler.c |
|||
gcc ${CFLAGS} -std=c99 -I/usr/local/include -L/usr/local/lib ${LIBS} -o testserver testserver.c test_handler.o ${TRLIBS} |
|||
gcc ${CFLAGS} -std=c99 -I/usr/local/include -L/usr/local/lib ${LIBS} -o testserver2 testserver2.c test_handler.o ${TRLIBS} |
|||
gcc ${CFLAGS} -std=c99 -I/usr/local/include -L/usr/local/lib ${LIBS} -o testtcp testclient.c ${TRLIBS} |
|||
gcc ${CFLAGS} -std=c99 -I/usr/local/include -L/usr/local/lib ${LIBS} -DUDP=1 -o testudp testclient.c ${TRLIBS} |
|||
@ -1,76 +0,0 @@ |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <inttypes.h> |
|||
|
|||
#include "trbase.h" |
|||
#include "trcomm.h" |
|||
#include "trevent.h" |
|||
|
|||
#include "test_handler.h" |
|||
|
|||
TR_INSTANCE(TR_LoggerSyslog, mylogger, {TR_LOGGER_DEBUG}); |
|||
|
|||
int |
|||
main (int argc, char * argv[]) |
|||
{ |
|||
TR_CommManager cmgr = (TR_CommManager)TR_new(TR_CommManagerPoll); |
|||
TR_EventDispatcher dispatcher = TR_new(TR_EventDispatcher); |
|||
TR_Connector connector = TR_new(TR_Connector); |
|||
TR_IoHandler io_handler = TR_new(TR_IoHandler); |
|||
TR_ProtocolHandler protocol_handler = TR_new(TR_ProtocolHandler); |
|||
TestHandler test_handler = TR_new(TestHandler); |
|||
TR_ConnEntryPoint tcp_ep; |
|||
TR_TcpSocket tcp_ep_sock; |
|||
TR_DatagramService udp_ep; |
|||
TR_UdpSocket udp_ep_sock; |
|||
TR_Protocol protocol; |
|||
|
|||
TR_logger = TR_INSTANCE_CAST(TR_Logger, mylogger); |
|||
|
|||
TR_eventDispatcherRegisterHandler(dispatcher, (TR_EventHandler)cmgr); |
|||
TR_eventDispatcherRegisterHandler(dispatcher, (TR_EventHandler)connector); |
|||
TR_eventDispatcherRegisterHandler(dispatcher, (TR_EventHandler)io_handler); |
|||
TR_eventDispatcherRegisterHandler( |
|||
dispatcher, |
|||
(TR_EventHandler)protocol_handler); |
|||
TR_eventDispatcherRegisterHandler( |
|||
dispatcher, |
|||
(TR_EventHandler)test_handler); |
|||
|
|||
protocol = TR_new(TR_ProtocolRaw); |
|||
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_eventDispatcherStart(dispatcher); |
|||
|
|||
puts("cleanup..."); |
|||
|
|||
TR_delete(cmgr); |
|||
TR_delete(dispatcher); |
|||
TR_delete(connector); |
|||
TR_delete(io_handler); |
|||
TR_delete(protocol_handler); |
|||
TR_delete(test_handler); |
|||
TR_delete(protocol); |
|||
//TR_delete(ep); |
|||
|
|||
TR_eventHandlerClassCleanup(TestHandler); |
|||
TR_eventHandlerClassCleanup(TR_ProtocolHandler); |
|||
TR_eventHandlerClassCleanup(TR_IoHandler); |
|||
TR_eventHandlerClassCleanup(TR_Connector); |
|||
TR_eventHandlerClassCleanup(TR_CommManagerPoll); |
|||
|
|||
TR_cleanup(); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue