|
| | TcpClient (const bool &TLS=false, const char *ca="", const char *cert="", const char *key="", const char *passwd="") |
| | TcpClient类的构造函数
|
| |
| bool | connect (const std::string &ip, const int &port) |
| | 向服务端发起tcp连接
|
| |
| void | resetCTX (const bool &TLS=false, const char *ca="", const char *cert="", const char *key="", const char *passwd="") |
| | 重新或第一次设置TLS加密参数
|
| |
| bool | close () |
| | 如果对象有套接字连接,关闭和释放这个连接和套接字,并且重新新建一个套接字。
|
| |
| | ~TcpClient () |
| | TcpClient的析构函数,会关闭释放套接字和其连接
|
| |
| std::string | getServerIP () |
| | 返回已连接的服务端的ip return 已连接的服务端的ip
|
| |
| int | getServerPort () |
| | 返回已连接的客户端的端口 return 已连接的服务端的端口
|
| |
| bool | isConnect () |
| | 返回对象的连接状态
|
| |
Public 成员函数 继承自 stt::network::TcpFDHandler |
| void | setFD (const int &fd, SSL *ssl, const bool &flag1=false, const bool &flag2=false, const int &sec=-1) |
| | 传入套接字初始化对象
|
| |
| void | setTransportFunctions (std::function< int(std::string)> sendFunction, std::function< void()> closeFunction={}) |
| | 由服务端 Reactor 注入异步发送和关闭通道。
|
| |
| int | getFD () |
| | 获取该对象的套接字
|
| |
| SSL * | getSSL () |
| | 获取该对象的加密SSL句柄
|
| |
| void | close (const bool &cle=true) |
| | 关闭对象
|
| |
| void | blockSet (const int &sec=-1) |
| | 设置对象中的套接字为阻塞模式
|
| |
| void | unblockSet () |
| | 设置对象中的套接字为非阻塞模式
|
| |
| bool | multiUseSet () |
| | 设置对象中的套接字为SO_REUSEADDR模式
|
| |
| bool | isConnect () |
| | 判断对象是否有套接字绑定
|
| |
| int | sendData (const std::string &data, const bool &block=true) |
| | 向已连接的套接字发送字符串数据。
|
| |
| int | sendData (const char *data, const uint64_t &length, const bool &block=true) |
| | 向已连接的套接字发送指定长度的二进制数据。
|
| |
| int | recvDataByLength (std::string &data, const uint64_t &length, const int &sec=2) |
| | 从已连接的套接字中阻塞接收指定长度的数据到字符串
|
| |
| int | recvDataByLength (char *data, const uint64_t &length, const int &sec=2) |
| | 从已连接的套接字中阻塞接收指定长度的数据到char*容器
|
| |
| int | recvData (std::string &data, const uint64_t &length) |
| | 从已连接的套接字中接收一次数据到string字符串容器
|
| |
| int | recvData (char *data, const uint64_t &length) |
| | 从已连接的套接字中接收一次数据到char*容器
|
| |