From 419af7d84199faedbaf68f756e8d1d7fd994068b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 4 Feb 2018 16:38:17 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_network.c | 10 +--------- iguana/exchanges/LP_peers.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index 95cb39e06..7cf5938dd 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -460,7 +460,7 @@ void LP_psockloop(void *_ptr) if ( iter == 0 ) { pfds[n].fd = ptr->publicsock; - printf("check sock.%d\n",ptr->publicsock); + //printf("check sock.%d\n",ptr->publicsock); pfds[n].events = POLLIN; } else @@ -787,7 +787,6 @@ int32_t LP_initpublicaddr(void *ctx,uint16_t *mypullportp,char *publicaddr,char { int32_t nntype,pullsock,timeout; char bindaddr[128],connectaddr[128]; *mypullportp = mypullport; - //connectaddr2[0] = 0; if ( ispaired == 0 ) { if ( LP_canbind != 0 ) @@ -798,7 +797,6 @@ int32_t LP_initpublicaddr(void *ctx,uint16_t *mypullportp,char *publicaddr,char { nanomsg_transportname(0,publicaddr,myipaddr,mypullport); nanomsg_transportname(1,bindaddr,myipaddr,mypullport); - //nanomsg_transportname2(1,bindaddr2,myipaddr,mypullport); } else { @@ -829,8 +827,6 @@ int32_t LP_initpublicaddr(void *ctx,uint16_t *mypullportp,char *publicaddr,char } else { - //if ( connectaddr2[0] != 0 && nn_connect(pullsock,connectaddr2) > 0 ) - // printf("%s ",connectaddr2); printf("nntype.%d NN_PAIR.%d connect to %s connectsock.%d\n",nntype,NN_PAIR,connectaddr,pullsock); } } @@ -841,14 +837,10 @@ int32_t LP_initpublicaddr(void *ctx,uint16_t *mypullportp,char *publicaddr,char printf("bind to %s error for %s: %s\n",bindaddr,publicaddr,nn_strerror(nn_errno())); exit(-1); } - //if ( nn_bind(pullsock,bindaddr2) >= 0 ) - // printf("bound to %s\n",bindaddr2); } timeout = 100; nn_setsockopt(pullsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout)); nn_setsockopt(pullsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout)); - //maxsize = 2 * 1024 * 1024; - //nn_setsockopt(pullsock,NN_SOL_SOCKET,NN_RCVBUF,&maxsize,sizeof(maxsize)); if ( nntype == NN_SUB ) nn_setsockopt(pullsock,NN_SUB,NN_SUB_SUBSCRIBE,"",0); } diff --git a/iguana/exchanges/LP_peers.c b/iguana/exchanges/LP_peers.c index 332d6ef61..50473a29a 100644 --- a/iguana/exchanges/LP_peers.c +++ b/iguana/exchanges/LP_peers.c @@ -59,22 +59,21 @@ char *LP_peers() void LP_cmdchannel(struct LP_peerinfo *peer) { char *hellostr = "{\"method\":\"hello\"}"; - char connectaddr[128],publicaddr[128],*retstr; int32_t i,pubsock,sentbytes=-2; uint16_t cmdport; + char connectaddr[128],publicaddr[128],*retstr; int32_t pairsock=-1,pubsock,sentbytes=-2; uint16_t cmdport; if ( bits256_nonz(G.LP_mypub25519) == 0 || strcmp(G.USERPASS,"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f") == 0 ) return; if ( (cmdport= LP_psock_get(connectaddr,publicaddr,1,1,peer->ipaddr)) != 0 ) { - if ( (retstr= _LP_psock_create(&peer->pairsock,&pubsock,peer->ipaddr,cmdport,cmdport,1,1,G.LP_mypub25519)) != 0 ) + if ( (retstr= _LP_psock_create(&pairsock,&pubsock,peer->ipaddr,cmdport,cmdport,1,1,G.LP_mypub25519)) != 0 ) { - for (i=0; i<30; i++) + if ( nn_connect(pairsock,connectaddr) < 0 ) + printf("error connecting cmdchannel with %s\n",connectaddr); + else { sentbytes = nn_send(peer->pairsock,hellostr,(int32_t)strlen(hellostr)+1,0); - if ( sentbytes > 0 ) - break; - printf("sentbytes.%d %s\n",sentbytes,nn_strerror(nn_errno())); - sleep(1); + printf("cmdchannel %d created %s sent.%d\n",peer->pairsock,retstr,sentbytes); + peer->pairsock = pairsock; } - printf("cmdchannel %d created %s sent.%d\n",peer->pairsock,retstr,sentbytes); free(retstr); } } else printf("error getting cmdchannel with %s\n",peer->ipaddr);