STTNet
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 宏定义 
Public 成员函数 | 所有成员列表
stt::network::UdpServer类 参考

udp服务端的操作类 更多...

#include <sttnet.h>

类 stt::network::UdpServer 继承关系图:
stt::network::UdpFDHandler

Public 成员函数

 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 成员函数 继承自 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*容器 更多...
 

额外继承的成员函数

- Protected 属性 继承自 stt::network::UdpFDHandler
int fd =-1
 
bool flag1 =false
 
bool flag2 =false
 
int sec =-1
 

详细描述

udp服务端的操作类

构造及析构函数说明

stt::network::UdpServer::UdpServer ( const int &  port,
const bool &  flag1 = false,
const int &  sec = -1,
const bool &  flag2 = true 
)

构造函数

参数
flag1true:设置非阻塞模式 false:设置阻塞模式 (默认为阻塞模式)
sec设置阻塞超时时间(秒) (默认为-1 即为无限等待)
flag2true:设置SO_REUSEADDR模式 false:不设置SO_REUSEADDR模式
stt::network::UdpServer::~UdpServer ( )
inline

析构函数,对象生命结束会会关闭套接字

成员函数说明

bool stt::network::UdpServer::createFD ( const int &  port,
const bool &  flag1 = false,
const int &  sec = -1,
const bool &  flag2 = true 
)

销毁原来的套接字,重新创建一个服务端

参数
flag1true:设置非阻塞模式 false:设置阻塞模式 (默认为阻塞模式)
sec设置阻塞超时时间(秒) (默认为-1 即为无限等待)
flag2true:设置SO_REUSEADDR模式 false:不设置SO_REUSEADDR模式

该类的文档由以下文件生成: