udp服务端的操作类
More...
#include <sttnet.h>
|
| | UdpServer (const int &port, const bool &flag1=false, const int &sec=-1, const bool &flag2=true) |
| | 构造函数
|
| |
| bool | createFD (const int &port, const bool &flag1=false, const int &sec=-1, const bool &flag2=true) |
| | 销毁原来的套接字,重新创建一个服务端
|
| |
| | ~UdpServer () |
| | 析构函数,对象生命结束会会关闭套接字
|
| |
Public Member Functions inherited from stt::network::UdpFDHandler |
| void | setFD (const int &fd, const bool &flag1=false, const int &sec=-1, const bool &flag2=false) |
| | 设置fd
|
| |
| void | blockSet (const int &sec=-1) |
| | 设置为阻塞模式
|
| |
| void | unblockSet () |
| | 设置为非阻塞模式
|
| |
| bool | multiUseSet () |
| | 设置SO_REUSEADDR模式
|
| |
| int | getFD () |
| | 返回fd
|
| |
| void | close (const bool &cle=true) |
| | 置空对象,关闭套接字
|
| |
| int | sendData (const std::string &data, const std::string &ip, const int &port, const bool &block=true) |
| | 向目标发送字符串数据。
|
| |
| int | sendData (const char *data, const uint64_t &length, const std::string &ip, const int &port, const bool &block=true) |
| | 向目标发送指定长度的二进制数据。
|
| |
| int | recvData (std::string &data, const uint64_t &length, std::string &ip, int &port) |
| | 接收一次数据到string字符串容器
|
| |
| int | recvData (char *data, const uint64_t &length, std::string &ip, int &port) |
| | 接收一次数据到char*容器
|
| |
◆ UdpServer()
| stt::network::UdpServer::UdpServer |
( |
const int & | port, |
|
|
const bool & | flag1 = false, |
|
|
const int & | sec = -1, |
|
|
const bool & | flag2 = true ) |
构造函数
- Parameters
-
| port | 本地监听端口。 |
| flag1 | true:设置非阻塞模式 false:设置阻塞模式 (默认为阻塞模式) |
| sec | 设置阻塞超时时间(秒) (默认为-1 即为无限等待) |
| flag2 | true:设置SO_REUSEADDR模式 false:不设置SO_REUSEADDR模式 |
◆ ~UdpServer()
| stt::network::UdpServer::~UdpServer |
( |
| ) |
|
|
inline |
◆ createFD()
| bool stt::network::UdpServer::createFD |
( |
const int & | port, |
|
|
const bool & | flag1 = false, |
|
|
const int & | sec = -1, |
|
|
const bool & | flag2 = true ) |
销毁原来的套接字,重新创建一个服务端
- Parameters
-
| port | 本地监听端口。 |
| flag1 | true:设置非阻塞模式 false:设置阻塞模式 (默认为阻塞模式) |
| sec | 设置阻塞超时时间(秒) (默认为-1 即为无限等待) |
| flag2 | true:设置SO_REUSEADDR模式 false:不设置SO_REUSEADDR模式 |
The documentation for this class was generated from the following file: