Added UDP sending support to socket library.

This commit is contained in:
Thulinma 2014-02-03 16:50:37 +01:00
parent 6420c42ac5
commit 773234f231
2 changed files with 127 additions and 0 deletions

View file

@ -118,5 +118,25 @@ namespace Socket {
void drop(); ///< Close connection without shutdown.
int getSocket(); ///< Returns internal socket number.
};
class UDPConnection{
private:
int sock; ///< Internally saved socket number.
std::string remotehost;///< Stores remote host address
void * destAddr;
unsigned int destAddr_size;
unsigned int up;
unsigned int down;
public:
UDPConnection(const UDPConnection & o); ///< Copy constructor
UDPConnection(bool nonblock = false); ///< Create new UDP socket
~UDPConnection();
void setBlocking(bool blocking); ///< Set this socket to be blocking (true) or nonblocking (false).
void SetDestination(std::string hostname, uint32_t port); ///< Sets the hostname and port destination for this UDP socket.
void Close();///< Closes the local socket
void SendNow(const std::string & data); ///< Will not buffer anything but always send right away. Blocks.
void SendNow(const char * data); ///< Will not buffer anything but always send right away. Blocks.
void SendNow(const char * data, size_t len); ///< Will not buffer anything but always send right away. Blocks.
};
}