Communication protocol handler for the taskrambler framework. This does not contain specific protocol implementations but the abstract code to handle them.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

74 lines
1.6 KiB

#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "trbase.h"
#include "trcomm.h"
#include "trio.h"
#include "trevent.h"
#include "test_handler.h"
TR_INSTANCE(TR_LoggerSyslog, mylogger, {TR_LOGGER_INFO});
TR_INSTANCE(TR_LoggerStderr, mylogger2, {TR_LOGGER_INFO});
int
main (int argc, char * argv[])
{
TR_TcpSocket socket;
TR_Connection connection;
TR_SimpleClient client;
TR_Protocol protocol;
TR_ProtoMessageRaw message;
int i;
TR_logger = TR_INSTANCE_CAST(TR_Logger, mylogger2);
socket = TR_new(TR_TcpSocket, TR_logger, "192.168.2.13", 5678, 0);
protocol = TR_new(TR_ProtocolRaw);
connection = TR_new(TR_Connection, socket, protocol);
TR_socketConnect((TR_Socket)socket);
TR_socketNonblock((TR_Socket)socket);
client = TR_new(TR_SimpleClient, connection);
for (i=0; i<100000; i++) {
message = (TR_ProtoMessageRaw)TR_protoCreateRequest(
protocol, (TR_Socket)socket);
message->size = sizeof("test");
message->data = TR_malloc(message->size);
memcpy(message->data, "test", sizeof("test"));
message = (TR_ProtoMessageRaw)TR_simpleClientIssue(
client,
(TR_ProtoMessage)message,
10000000);
#if 0
printf("%s\n", message->data);
#else
if (0 == strncmp("test", message->data, sizeof("test")-1)) {
if (i % 1000 == 0) printf("%c", '.');
} else {
printf("%c", 'f');
}
#endif
fflush(stdout);
TR_delete(message);
}
puts("");
puts("cleanup...");
TR_delete(client);
TR_delete(protocol);
TR_simpleClientClassCleanup();
TR_cleanup();
return 0;
}
// vim: set ts=4 sw=4: