From acd4a7f32d55dda0edb4901b80ffd0cf6e6fa25f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Jun 2017 13:29:47 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_forwarding.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_forwarding.c b/iguana/exchanges/LP_forwarding.c index 34da1ee06..f486faf1b 100644 --- a/iguana/exchanges/LP_forwarding.c +++ b/iguana/exchanges/LP_forwarding.c @@ -50,27 +50,31 @@ char *LP_lookup(bits256 pubkey) int32_t LP_pushsock_create(char *pushaddr) { - int32_t pushsock,timeout,i; struct nn_pollfd pfd; + int32_t pushsock,timeout,i,n=1000; struct nn_pollfd pfd; if ( (pushsock= nn_socket(AF_SP,NN_PUSH)) < 0 ) + { + printf("LP_pushsock_create couldnt allocate socket for %s\n",pushaddr); return(-1); + } else if ( nn_connect(pushsock,pushaddr) < 0 ) { nn_close(pushsock); + printf("LP_pushsock_create couldnt connect to %s\n",pushaddr); return(-1); } timeout = 1; nn_setsockopt(pushsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout)); pfd.fd = pushsock; pfd.events = NN_POLLOUT; - for (i=0; i<1000; i++) + for (i=0; i 0 ) { - printf("HELLO sent.%d bytes\n",LP_send(pushsock,"{\"method\":\"hello\"}",0)); + printf("HELLO sent.%d bytes to %s\n",LP_send(pushsock,"{\"method\":\"hello\"}",0),pushaddr); break; } } - if ( i == 100 ) + if ( i == n ) printf("%d iterations on nn_poll and %s pushsock still not ready\n",i,pushaddr); return(pushsock); }