Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fffbef43
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fffbef43
编写于
8月 25, 2020
作者:
H
Hui Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-1132]
上级
66a977df
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
4 deletion
+27
-4
src/kit/taosnetwork/client.c
src/kit/taosnetwork/client.c
+27
-4
未找到文件。
src/kit/taosnetwork/client.c
浏览文件 @
fffbef43
...
...
@@ -105,6 +105,18 @@ int checkTcpPort(info_s *info) {
printf
(
"socket() fail: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
}
// set send and recv overtime
struct
timeval
timeout
;
timeout
.
tv_sec
=
2
;
//s
timeout
.
tv_usec
=
0
;
//us
if
(
setsockopt
(
clientSocket
,
SOL_SOCKET
,
SO_SNDTIMEO
,
(
char
*
)
&
timeout
,
sizeof
(
struct
timeval
))
==
-
1
)
{
perror
(
"setsockopt send timer failed:"
);
}
if
(
setsockopt
(
clientSocket
,
SOL_SOCKET
,
SO_RCVTIMEO
,
(
char
*
)
&
timeout
,
sizeof
(
struct
timeval
))
==
-
1
)
{
perror
(
"setsockopt recv timer failed:"
);
}
serverAddr
.
sin_family
=
AF_INET
;
serverAddr
.
sin_port
=
htons
(
info
->
port
);
...
...
@@ -112,7 +124,7 @@ int checkTcpPort(info_s *info) {
//printf("=================================\n");
if
(
connect
(
clientSocket
,
(
struct
sockaddr
*
)
&
serverAddr
,
sizeof
(
serverAddr
))
<
0
)
{
printf
(
"connect() fail: %s
\
n
"
,
strerror
(
errno
));
printf
(
"connect() fail: %s
\
t
"
,
strerror
(
errno
));
return
-
1
;
}
//printf("Connect to: %s:%d...success\n", host, port);
...
...
@@ -171,6 +183,17 @@ int checkUdpPort(info_s *info) {
perror
(
"socket"
);
return
-
1
;
}
// set overtime
struct
timeval
timeout
;
timeout
.
tv_sec
=
2
;
//s
timeout
.
tv_usec
=
0
;
//us
if
(
setsockopt
(
clientSocket
,
SOL_SOCKET
,
SO_SNDTIMEO
,
(
char
*
)
&
timeout
,
sizeof
(
struct
timeval
))
==
-
1
)
{
perror
(
"setsockopt send timer failed:"
);
}
if
(
setsockopt
(
clientSocket
,
SOL_SOCKET
,
SO_RCVTIMEO
,
(
char
*
)
&
timeout
,
sizeof
(
struct
timeval
))
==
-
1
)
{
perror
(
"setsockopt recv timer failed:"
);
}
serverAddr
.
sin_family
=
AF_INET
;
serverAddr
.
sin_port
=
htons
(
info
->
port
);
...
...
@@ -195,7 +218,7 @@ int checkUdpPort(info_s *info) {
iDataNum
=
recvfrom
(
clientSocket
,
recvbuf
,
BUFFER_SIZE
,
0
,
(
struct
sockaddr
*
)
&
serverAddr
,
&
sin_size
);
if
(
iDataNum
<
info
->
pktLen
)
{
printf
(
"Read ack pkg len: %d, less than req pkg len: %d from udp port: %d
\
n
"
,
iDataNum
,
info
->
pktLen
,
info
->
port
);
printf
(
"Read ack pkg len: %d, less than req pkg len: %d from udp port: %d
\
t\t
"
,
iDataNum
,
info
->
pktLen
,
info
->
port
);
return
-
1
;
}
...
...
@@ -239,14 +262,14 @@ void checkPort(uint32_t hostIp, uint16_t startPort, uint16_t maxPort, uint16_t p
info
.
port
=
port
;
ret
=
checkTcpPort
(
&
info
);
if
(
ret
!=
0
)
{
printf
(
"tcp port:%d test fail.
\t\
t
"
,
port
);
printf
(
"tcp port:%d test fail.
\t\
n
"
,
port
);
}
else
{
printf
(
"tcp port:%d test ok.
\t\t
"
,
port
);
}
ret
=
checkUdpPort
(
&
info
);
if
(
ret
!=
0
)
{
printf
(
"udp port:%d test fail.
\t\
t
"
,
port
);
printf
(
"udp port:%d test fail.
\t\
n
"
,
port
);
}
else
{
printf
(
"udp port:%d test ok.
\t\t
"
,
port
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录