• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the openHiTLS project.
3  *
4  * openHiTLS is licensed under the Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *
8  *     http://license.coscl.org.cn/MulanPSL2
9  *
10  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13  * See the Mulan PSL v2 for more details.
14  */
15 
16 #ifndef TCP_CHANNEL_H
17 #define TCP_CHANNEL_H
18 
19 #include <stdbool.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /* Connects to the peer and returns a socket descriptor. */
26 int TcpConnect(const char *targetIP, const int targetPort);
27 
28 /* listen */
29 int TcpBind(const int localPort);
30 
31 /* accept */
32 int TcpAccept(char *ip, int listenFd, bool isBlock, bool needClose);
33 
34 /* write */
35 int32_t TcpFrameWrite(BSL_UIO *uio, const void *buf, uint32_t len, uint32_t *writeLen);
36 
37 /*
38  * When the Windows TCP server is used, the socket that is closed accept cannot be cleaned up.
39  * Otherwise, the next accept operation will fail
40  */
41 void TcpClose(int sd);
42 
43 /* Default TCP method based on Linux */
44 void *TcpGetDefaultMethod(void);
45 
46 #ifdef __cplusplus
47 }
48 #endif
49 
50 #endif  // TCP_CHANNEL_H
51