STTNet
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
stt::network::UdpServer Class Reference

Udp server operation class. More...

#include <sttnet_English.h>

Inheritance diagram for stt::network::UdpServer:
stt::network::UdpFDHandler

Public Member Functions

 UdpServer (const int &port, const bool &flag1=false, const int &sec=-1, const bool &flag2=true)
 Constructor. More...
 
bool createFD (const int &port, const bool &flag1=false, const int &sec=-1, const bool &flag2=true)
 Destroy the original socket and recreate a server. More...
 
 ~UdpServer ()
 Destructor, closes the socket when the object's life ends. More...
 
- 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)
 Set fd. More...
 
void blockSet (const int &sec=-1)
 Set to blocking mode. More...
 
void unblockSet ()
 Set to non-blocking mode. More...
 
bool multiUseSet ()
 Set SO_REUSEADDR mode. More...
 
int getFD ()
 Return fd. More...
 
void close (const bool &cle=true)
 Empty the object and close the socket. More...
 
int sendData (const std::string &data, const std::string &ip, const int &port, const bool &block=true)
 Send string data to the target. More...
 
int sendData (const char *data, const uint64_t &length, const std::string &ip, const int &port, const bool &block=true)
 Send a specified length of binary data to the target. More...
 
int recvData (std::string &data, const uint64_t &length, std::string &ip, int &port)
 Receive data once into a string container. More...
 
int recvData (char *data, const uint64_t &length, std::string &ip, int &port)
 Receive data once into a char* container. More...
 

Additional Inherited Members

- Protected Attributes inherited from stt::network::UdpFDHandler
int fd = -1
 
bool flag1 = false
 
bool flag2 = false
 
int sec = -1
 

Detailed Description

Udp server operation class.

Constructor & Destructor Documentation

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

Constructor.

Parameters
portPort number
flag1true: Set to non-blocking mode, false: Set to blocking mode (default is blocking mode)
secSet blocking timeout (seconds) (default is -1, i.e., infinite wait)
flag2true: Set SO_REUSEADDR mode, false: Do not set SO_REUSEADDR mode
stt::network::UdpServer::~UdpServer ( )
inline

Destructor, closes the socket when the object's life ends.

Member Function Documentation

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

Destroy the original socket and recreate a server.

Parameters
flag1true: Set to non-blocking mode, false: Set to blocking mode (default is blocking mode)
secSet blocking timeout (seconds) (default is -1, i.e., infinite wait)
flag2true: Set SO_REUSEADDR mode, false: Do not set SO_REUSEADDR mode

The documentation for this class was generated from the following file: