Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ada04eb2
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ada04eb2
编写于
10月 23, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rm [èredundance
上级
e7014c3e
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
50 addition
and
28 deletion
+50
-28
source/os/src/osSocket.c
source/os/src/osSocket.c
+50
-28
未找到文件。
source/os/src/osSocket.c
浏览文件 @
ada04eb2
...
...
@@ -73,6 +73,7 @@ typedef struct TdEpoll {
EpollFd
fd
;
}
*
TdEpollPtr
,
TdEpoll
;
#if 0
int32_t taosSendto(TdSocketPtr pSocket, void *buf, int len, unsigned int flags, const struct sockaddr *dest_addr,
int addrlen) {
if (pSocket == NULL || pSocket->fd < 0) {
...
...
@@ -84,6 +85,7 @@ int32_t taosSendto(TdSocketPtr pSocket, void *buf, int len, unsigned int flags,
return sendto(pSocket->fd, buf, len, flags, dest_addr, addrlen);
#endif
}
int32_t
taosWriteSocket
(
TdSocketPtr
pSocket
,
void
*
buf
,
int
len
)
{
if
(
pSocket
==
NULL
||
pSocket
->
fd
<
0
)
{
return
-
1
;
...
...
@@ -114,6 +116,8 @@ int32_t taosReadFromSocket(TdSocketPtr pSocket, void *buf, int32_t len, int32_t
}
return
recvfrom
(
pSocket
->
fd
,
buf
,
len
,
flags
,
destAddr
,
addrLen
);
}
#endif // endif 0
int32_t
taosCloseSocketNoCheck1
(
SocketFd
fd
)
{
#ifdef WINDOWS
return
closesocket
(
fd
);
...
...
@@ -121,6 +125,7 @@ int32_t taosCloseSocketNoCheck1(SocketFd fd) {
return
close
(
fd
);
#endif
}
int32_t
taosCloseSocket
(
TdSocketPtr
*
ppSocket
)
{
int32_t
code
;
if
(
ppSocket
==
NULL
||
*
ppSocket
==
NULL
||
(
*
ppSocket
)
->
fd
<
0
)
{
...
...
@@ -131,6 +136,8 @@ int32_t taosCloseSocket(TdSocketPtr *ppSocket) {
taosMemoryFree
(
*
ppSocket
);
return
code
;
}
#if 0
int32_t taosCloseSocketServer(TdSocketServerPtr *ppSocketServer) {
int32_t code;
if (ppSocketServer == NULL || *ppSocketServer == NULL || (*ppSocketServer)->fd < 0) {
...
...
@@ -262,6 +269,8 @@ int32_t taosSetNonblocking(TdSocketPtr pSocket, int32_t on) {
#endif
return
0
;
}
#endif // endif 0
int32_t
taosSetSockOpt
(
TdSocketPtr
pSocket
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
optlen
)
{
if
(
pSocket
==
NULL
||
pSocket
->
fd
<
0
)
{
return
-
1
;
...
...
@@ -296,6 +305,8 @@ int32_t taosSetSockOpt(TdSocketPtr pSocket, int32_t level, int32_t optname, void
return
setsockopt
(
pSocket
->
fd
,
level
,
optname
,
optval
,
(
int
)
optlen
);
#endif
}
#if 0
int32_t taosGetSockOpt(TdSocketPtr pSocket, int32_t level, int32_t optname, void *optval, int32_t *optlen) {
if (pSocket == NULL || pSocket->fd < 0) {
return -1;
...
...
@@ -307,6 +318,9 @@ int32_t taosGetSockOpt(TdSocketPtr pSocket, int32_t level, int32_t optname, void
return getsockopt(pSocket->fd, level, optname, optval, (int *)optlen);
#endif
}
#endif
uint32_t
taosInetAddr
(
const
char
*
ipAddr
)
{
#ifdef WINDOWS
uint32_t
value
;
...
...
@@ -330,6 +344,7 @@ const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len) {
#define TCP_CONN_TIMEOUT 3000 // conn timeout
#if 0
int32_t taosWriteMsg(TdSocketPtr pSocket, void *buf, int32_t nbytes) {
if (pSocket == NULL || pSocket->fd < 0) {
return -1;
...
...
@@ -724,6 +739,7 @@ int taosValidIp(uint32_t ip) {
#endif
return
0
;
}
#endif // endif 0
bool
taosValidIpAndPort
(
uint32_t
ip
,
uint16_t
port
)
{
struct
sockaddr_in
serverAdd
;
...
...
@@ -772,6 +788,8 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
return
true
;
// return 0 == taosValidIp(ip) ? true : false;
}
#if 0
TdSocketServerPtr taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
struct sockaddr_in serverAdd;
SocketFd fd;
...
...
@@ -886,6 +904,36 @@ int64_t taosCopyFds(TdSocketPtr pSrcSocket, TdSocketPtr pDestSocket, int64_t len
return len;
}
// Function converting an IP address string to an uint32_t.
uint32_t ip2uint(const char *const ip_addr) {
char ip_addr_cpy[20];
char ip[5];
tstrncpy(ip_addr_cpy, ip_addr, sizeof(ip_addr_cpy));
char *s_start, *s_end;
s_start = ip_addr_cpy;
s_end = ip_addr_cpy;
int32_t k;
for (k = 0; *s_start != '\0'; s_start = s_end) {
for (s_end = s_start; *s_end != '.' && *s_end != '\0'; s_end++) {
}
if (*s_end == '.') {
*s_end = '\0';
s_end++;
}
ip[k++] = (char)atoi(s_start);
}
ip[k] = '\0';
return *((uint32_t *)ip);
}
#endif // endif 0
void
taosBlockSIGPIPE
()
{
#ifdef WINDOWS
// assert(0);
...
...
@@ -989,34 +1037,6 @@ int32_t taosGetFqdn(char *fqdn) {
return
0
;
}
// Function converting an IP address string to an uint32_t.
uint32_t
ip2uint
(
const
char
*
const
ip_addr
)
{
char
ip_addr_cpy
[
20
];
char
ip
[
5
];
tstrncpy
(
ip_addr_cpy
,
ip_addr
,
sizeof
(
ip_addr_cpy
));
char
*
s_start
,
*
s_end
;
s_start
=
ip_addr_cpy
;
s_end
=
ip_addr_cpy
;
int32_t
k
;
for
(
k
=
0
;
*
s_start
!=
'\0'
;
s_start
=
s_end
)
{
for
(
s_end
=
s_start
;
*
s_end
!=
'.'
&&
*
s_end
!=
'\0'
;
s_end
++
)
{
}
if
(
*
s_end
==
'.'
)
{
*
s_end
=
'\0'
;
s_end
++
;
}
ip
[
k
++
]
=
(
char
)
atoi
(
s_start
);
}
ip
[
k
]
=
'\0'
;
return
*
((
uint32_t
*
)
ip
);
}
void
tinet_ntoa
(
char
*
ipstr
,
uint32_t
ip
)
{
sprintf
(
ipstr
,
"%d.%d.%d.%d"
,
ip
&
0xFF
,
(
ip
>>
8
)
&
0xFF
,
(
ip
>>
16
)
&
0xFF
,
ip
>>
24
);
}
...
...
@@ -1037,12 +1057,14 @@ void taosSetMaskSIGPIPE() {
#endif
}
#if 0
int32_t taosGetSocketName(TdSocketPtr pSocket, struct sockaddr *destAddr, int *addrLen) {
if (pSocket == NULL || pSocket->fd < 0) {
return -1;
}
return getsockname(pSocket->fd, destAddr, addrLen);
}
#endif // endif 0
/*
* Set TCP connection timeout per-socket level.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录