1 #include "opensrf/transport_client.h"
5 /* connects and registers with the router */
6 int main( int argc, char** argv ) {
9 fatal_handler( "Usage: %s <server> <port> <name> <secret>", argv[0] );
12 int port = atoi(argv[2]);
13 transport_client* client = client_init( argv[1], port, 1 );
15 // try to connect, allow 15 second connect timeout
16 if( client_connect( client, argv[3], argv[4], "", 15 ) )
17 info_handler("Connected...\n");
19 fatal_handler( "NOT Connected...\n" );
21 transport_message* recv;
22 while( (recv=client_recv( client, -1)) ) {
24 fprintf( stderr, "\nReceived Error\t: ------------------\nFrom:\t\t"
25 "%s\nRouterFrom:\t%s\nBody:\t\t%s\nType %s\nCode %d\n=> ",
26 recv->sender, recv->router_from, recv->body, recv->error_type, recv->error_code );
28 fprintf( stderr, "\nReceived\t: ------------------\nFrom:\t\t"
29 "%s\nRouterFrom:\t%s\nBody:\t\t%s\n=> ", recv->sender, recv->router_from, recv->body );
30 transport_message* send = message_init( "Hello...", "", "123454321", recv->sender, argv[3] );
31 client_send_message( client, send );