提交 c755056d 编写于 作者: H Hui Li

[TD-1076]

上级 7f9e0928
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#define MAX_PKG_LEN (16*1000) #define MAX_PKG_LEN (64*1000)
#define BUFFER_SIZE (MAX_PKG_LEN + 1024) #define BUFFER_SIZE (MAX_PKG_LEN + 1024)
typedef struct { typedef struct {
...@@ -107,9 +107,32 @@ int checkTcpPort(info_s *info) { ...@@ -107,9 +107,32 @@ int checkTcpPort(info_s *info) {
send(clientSocket, sendbuf, info->pktLen, 0); 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) { 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; return -1;
} }
//printf("Read ack pkg len:%d from tcp port: %d, buffer: %s %s\n", info->pktLen, port, recvbuf, recvbuf+iDataNum-8); //printf("Read ack pkg len:%d from tcp port: %d, buffer: %s %s\n", info->pktLen, port, recvbuf, recvbuf+iDataNum-8);
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <unistd.h> #include <unistd.h>
#include <pthread.h> #include <pthread.h>
#define MAX_PKG_LEN (16*1000) #define MAX_PKG_LEN (64*1000)
#define BUFFER_SIZE (MAX_PKG_LEN + 1024) #define BUFFER_SIZE (MAX_PKG_LEN + 1024)
typedef struct { typedef struct {
...@@ -119,7 +119,7 @@ static void *bindTcpPort(void *sarg) { ...@@ -119,7 +119,7 @@ static void *bindTcpPort(void *sarg) {
char *ptr = buffer; char *ptr = buffer;
nleft = pinfo->pktLen; nleft = pinfo->pktLen;
while (nleft > 0) { while (nleft > 0) {
nread = recv(client, buffer, BUFFER_SIZE, 0); nread = recv(client, ptr, BUFFER_SIZE, 0);
if (nread == 0) { if (nread == 0) {
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册