diff --git a/src/kit/taosnetwork/client.c b/src/kit/taosnetwork/client.c index a4fc26f22f39b0979e70a2e7b0234715d99a3a60..26e292a1befe59ddcf14a19d702cda800bee02a5 100644 --- a/src/kit/taosnetwork/client.c +++ b/src/kit/taosnetwork/client.c @@ -28,7 +28,7 @@ #include #include -#define MAX_PKG_LEN (16*1000) +#define MAX_PKG_LEN (64*1000) #define BUFFER_SIZE (MAX_PKG_LEN + 1024) typedef struct { @@ -107,9 +107,32 @@ int checkTcpPort(info_s *info) { send(clientSocket, sendbuf, info->pktLen, 0); - iDataNum = recv(clientSocket, recvbuf, BUFFER_SIZE, 0); + memset(recvbuf, 0, BUFFER_SIZE); + int nleft, nread; + char *ptr = recvbuf; + nleft = info->pktLen; + while (nleft > 0) { + nread = recv(clientSocket, ptr, BUFFER_SIZE, 0);; + + if (nread == 0) { + break; + } else if (nread < 0) { + if (errno == EINTR) { + continue; + } else { + printf("recv ack pkg from TCP port: %d fail:%s.\n", port, strerror(errno)); + close(clientSocket); + return -1; + } + } else { + nleft -= nread; + ptr += nread; + iDataNum += nread; + } + } + if (iDataNum < info->pktLen) { - printf("Read ack pkg len: %d, less than req pkg len: %d from tcp port: %d\n", iDataNum, info->pktLen, port); + printf("recv ack pkg len: %d, less than req pkg len: %d from tcp port: %d\n", iDataNum, info->pktLen, port); return -1; } //printf("Read ack pkg len:%d from tcp port: %d, buffer: %s %s\n", info->pktLen, port, recvbuf, recvbuf+iDataNum-8); diff --git a/src/kit/taosnetwork/server.c b/src/kit/taosnetwork/server.c index 18565edb3ff4f7c6cf82ce5988870ffb76e63712..b18fbde46ea00f629d254d786f81d18c67bdcdf4 100644 --- a/src/kit/taosnetwork/server.c +++ b/src/kit/taosnetwork/server.c @@ -29,7 +29,7 @@ #include #include -#define MAX_PKG_LEN (16*1000) +#define MAX_PKG_LEN (64*1000) #define BUFFER_SIZE (MAX_PKG_LEN + 1024) typedef struct { @@ -119,7 +119,7 @@ static void *bindTcpPort(void *sarg) { char *ptr = buffer; nleft = pinfo->pktLen; while (nleft > 0) { - nread = recv(client, buffer, BUFFER_SIZE, 0); + nread = recv(client, ptr, BUFFER_SIZE, 0); if (nread == 0) { break;