提交 7f885cb3 编写于 作者: S Shengliang Guan

TD-1057

上级 8ac389c6
...@@ -91,7 +91,7 @@ int checkTcpPort(info_s *info) { ...@@ -91,7 +91,7 @@ int checkTcpPort(info_s *info) {
serverAddr.sin_family = AF_INET; serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(port); serverAddr.sin_port = htons(port);
serverAddr.sin_addr.s_addr = taosInetAddr(host); serverAddr.sin_addr.s_addr = inet_addr(host);
//printf("=================================\n"); //printf("=================================\n");
if (connect(clientSocket, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) < 0) { if (connect(clientSocket, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) < 0) {
...@@ -157,7 +157,7 @@ int checkUdpPort(info_s *info) { ...@@ -157,7 +157,7 @@ int checkUdpPort(info_s *info) {
serverAddr.sin_family = AF_INET; serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(port); serverAddr.sin_port = htons(port);
serverAddr.sin_addr.s_addr = taosInetAddr(host); serverAddr.sin_addr.s_addr = inet_addr(host);
memset(sendbuf, 0, BUFFER_SIZE); memset(sendbuf, 0, BUFFER_SIZE);
memset(recvbuf, 0, BUFFER_SIZE); memset(recvbuf, 0, BUFFER_SIZE);
......
...@@ -128,7 +128,7 @@ static void *bindTcpPort(void *sarg) { ...@@ -128,7 +128,7 @@ static void *bindTcpPort(void *sarg) {
if (errno == EINTR) { if (errno == EINTR) {
continue; continue;
} else { } else {
printf("recv Client: %s pkg from TCP port: %d fail:%s.\n", taosInetNtoa(clientAddr.sin_addr), port, strerror(errno)); printf("recv Client: %s pkg from TCP port: %d fail:%s.\n", inet_ntoa(clientAddr.sin_addr), port, strerror(errno));
close(serverSocket); close(serverSocket);
return NULL; return NULL;
} }
...@@ -139,7 +139,7 @@ static void *bindTcpPort(void *sarg) { ...@@ -139,7 +139,7 @@ static void *bindTcpPort(void *sarg) {
} }
} }
printf("recv Client: %s pkg from TCP port: %d, pkg len: %d\n", taosInetNtoa(clientAddr.sin_addr), port, iDataNum); printf("recv Client: %s pkg from TCP port: %d, pkg len: %d\n", inet_ntoa(clientAddr.sin_addr), port, iDataNum);
if (iDataNum > 0) { if (iDataNum > 0) {
send(client, buffer, iDataNum, 0); send(client, buffer, iDataNum, 0);
break; break;
...@@ -188,7 +188,7 @@ static void *bindUdpPort(void *sarg) { ...@@ -188,7 +188,7 @@ static void *bindUdpPort(void *sarg) {
continue; continue;
} }
if (iDataNum > 0) { if (iDataNum > 0) {
printf("recv Client: %s pkg from UDP port: %d, pkg len: %d\n", taosInetNtoa(clientAddr.sin_addr), port, iDataNum); printf("recv Client: %s pkg from UDP port: %d, pkg len: %d\n", inet_ntoa(clientAddr.sin_addr), port, iDataNum);
//printf("Read msg from udp:%s ... %s\n", buffer, buffer+iDataNum-16); //printf("Read msg from udp:%s ... %s\n", buffer, buffer+iDataNum-16);
sendto(serverSocket, buffer, iDataNum, 0, (struct sockaddr *)&clientAddr, (int)sin_size); sendto(serverSocket, buffer, iDataNum, 0, (struct sockaddr *)&clientAddr, (int)sin_size);
......
...@@ -67,7 +67,7 @@ int taosSetSockOpt(SOCKET socketfd, int level, int optname, void *optval, int op ...@@ -67,7 +67,7 @@ int taosSetSockOpt(SOCKET socketfd, int level, int optname, void *optval, int op
// TAOS_OS_FUNC_SOCKET_INET // TAOS_OS_FUNC_SOCKET_INET
uint32_t taosInetAddr(char *ipAddr); uint32_t taosInetAddr(char *ipAddr);
const char *taosInetNtoa(IN_ADDR ipInt); const char *taosInetNtoa(struct in_addr ipInt);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -65,7 +65,7 @@ uint32_t taosInetAddr(char *ipAddr) { ...@@ -65,7 +65,7 @@ uint32_t taosInetAddr(char *ipAddr) {
return inet_addr(ipAddr); return inet_addr(ipAddr);
} }
const char *taosInetNtoa(IN_ADDR ipInt) { const char *taosInetNtoa(struct in_addr ipInt) {
return inet_ntoa(ipInt); return inet_ntoa(ipInt);
} }
......
...@@ -76,7 +76,7 @@ uint32_t taosInetAddr(char *ipAddr) { ...@@ -76,7 +76,7 @@ uint32_t taosInetAddr(char *ipAddr) {
} }
} }
const char *taosInetNtoa(IN_ADDR ipInt) { const char *taosInetNtoa(struct in_addr ipInt) {
// not thread safe, only for debug usage while print log // not thread safe, only for debug usage while print log
static char tmpDstStr[16]; static char tmpDstStr[16];
return inet_ntop(AF_INET, &ipInt, tmpDstStr, INET6_ADDRSTRLEN); return inet_ntop(AF_INET, &ipInt, tmpDstStr, INET6_ADDRSTRLEN);
......
...@@ -323,7 +323,7 @@ static void *httpAcceptHttpConnection(void *arg) { ...@@ -323,7 +323,7 @@ static void *httpAcceptHttpConnection(void *arg) {
} }
pContext->pThread = pThread; pContext->pThread = pThread;
sprintf(pContext->ipstr, "%s:%u", taosInetAddr(clientAddr.sin_addr), htons(clientAddr.sin_port)); sprintf(pContext->ipstr, "%s:%u", taosInetNtoa(clientAddr.sin_addr), htons(clientAddr.sin_port));
struct epoll_event event; struct epoll_event event;
event.events = EPOLLIN | EPOLLPRI | EPOLLWAKEUP | EPOLLERR | EPOLLHUP | EPOLLRDHUP; event.events = EPOLLIN | EPOLLPRI | EPOLLWAKEUP | EPOLLERR | EPOLLHUP | EPOLLRDHUP;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册