Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
469ee78987
  1. 20
      iguana/SuperNET.c

20
iguana/SuperNET.c

@ -423,14 +423,14 @@ int32_t nn_reqsocket(struct supernet_info *myinfo,uint16_t LBport,uint16_t PUBpo
int32_t SuperNET_send(struct supernet_info *myinfo,int32_t sock,bits256 *dest,uint8_t type,struct supernet_msghdr *msg,char *agent,uint8_t *data,int32_t datalen,uint32_t duration,uint32_t nonce)
{
int32_t i,sendlen = -1;
int32_t sendlen = -1;
if ( nonce == 0 )
OS_randombytes((void *)&nonce,sizeof(nonce));
if ( (msg= SuperNET_msgcreate(myinfo,type,&myinfo->myaddr.pubkey,dest,msg,sizeof(*msg)+datalen,agent,data,datalen,duration,nonce)) != 0 )
{
for (i=0; i<10; i++)
if ( (nn_socket_status(sock,1) & NN_POLLOUT) != 0 )
break;
//for (i=0; i<10; i++)
// if ( (nn_socket_status(sock,1) & NN_POLLOUT) != 0 )
// break;
if ( (sendlen= nn_send(sock,msg,sizeof(*msg)+datalen,0)) != sizeof(*msg)+datalen )
printf("SuperNET_send sendlen.%d != len.%ld\n",sendlen,sizeof(*msg)+datalen);
else printf("SuperNET_send.(%s).%u sendlen.%d\n",msg->agent,nonce,sendlen);
@ -534,9 +534,9 @@ int32_t SuperNET_LBrequest(struct supernet_info *myinfo,bits256 *dest,uint8_t ty
{
retmsg = (void *)myinfo->recvbuf[1];
iguana_rwnum(0,msg->ser_nonce,sizeof(nonce),&nonce);
for (i=0; i<10; i++)
if ( (nn_socket_status(sock,1) & NN_POLLIN) != 0 )
break;
//for (i=0; i<10; i++)
// if ( (nn_socket_status(sock,1) & NN_POLLIN) != 0 )
// break;
if ( (recvlen= nn_recv(sock,retmsg,SUPERNET_MAXRECVBUF,0)) > 0 )
{
printf("LBrequest recvlen.%d nonce.%u\n",recvlen,nonce);
@ -564,9 +564,9 @@ void SuperNET_recv(struct supernet_info *myinfo,int32_t sock,int32_t LBreq)
myinfo->recvbuf[LBreq] = calloc(1,SUPERNET_MAXRECVBUF+sizeof(*msg));
if ( myinfo->recvbuf[LBreq + 1] == 0 )
myinfo->recvbuf[LBreq + 1] = calloc(1,SUPERNET_MAXRECVBUF+sizeof(*msg));
for (i=0; i<10; i++)
if ( (nn_socket_status(sock,1) & NN_POLLIN) != 0 )
break;
//for (i=0; i<10; i++)
// if ( (nn_socket_status(sock,1) & NN_POLLIN) != 0 )
// break;
if ( (recvlen= nn_recv(sock,myinfo->recvbuf[LBreq],SUPERNET_MAXRECVBUF,0)) > 0 )
{
msg = (void *)myinfo->recvbuf[LBreq];

Loading…
Cancel
Save