1 #include "transport_client.h"
6 void print_stuff(void* blah, char* data) {
7 fprintf(stderr, "Received from socket: %s\n", data);
11 /* connects and registers with the router */
12 int main( int argc, char** argv ) {
17 osrfLogError(OSRF_LOG_MARK, "Usage: %s <server> <port> <name> <secret>", argv[0] );
21 int port = atoi(argv[2]);
22 transport_client* client = client_init( argv[1], port, 1 );
24 // try to connect, allow 15 second connect timeout
25 if( client_connect( client, argv[3], argv[4], "", 15, 1 ) )
26 osrfLogInfo(OSRF_LOG_MARK, "Connected...\n");
28 osrfLogError(OSRF_LOG_MARK, "NOT Connected...\n" );
32 transport_message* recv;
33 while( (recv=client_recv( client, -1)) ) {
35 fprintf( stderr, "\nReceived Error\t: ------------------\nFrom:\t\t"
36 "%s\nRouterFrom:\t%s\nBody:\t\t%s\nType %s\nCode %d\n=> ",
37 recv->sender, recv->router_from, recv->body, recv->error_type, recv->error_code );
39 fprintf( stderr, "\nReceived\t: ------------------\nFrom:\t\t"
40 "%s\nRouterFrom:\t%s\nBody:\t\t%s\n=> ", recv->sender, recv->router_from, recv->body );
41 transport_message* send = message_init( "Hello...", "", "123454321", recv->sender, argv[3] );
42 client_send_message( client, send );