603515dd3e
The tests seem to work: ./test/test_FileIO ./test/test_FileIO ./test/test_FileIO ./test/test_FileIO | \ ./test/test_SafeUDPpacket -f - ./test/test_SafeUDPpacket -f ./test/test_SafeUDPpacket
49 lines
938 B
C++
49 lines
938 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <SDL_net.h>
|
|
|
|
#define DEFAULT_MAX_PACKET_SIZE 512
|
|
|
|
class
|
|
UDPbase
|
|
{
|
|
int m_channel;
|
|
IPaddress m_address;
|
|
void CloseAllSockets (void);
|
|
|
|
protected:
|
|
std::vector<UDPsocket> m_socks;
|
|
public:
|
|
UDPbase (const char*, const Uint16);
|
|
UDPbase (const char*, const Uint16, const int);
|
|
~UDPbase (void);
|
|
|
|
int ResolveHost (IPaddress*, const char*, const Uint16);
|
|
|
|
UDPsocket UDP_Open (void);
|
|
UDPsocket UDP_Open (const Uint16 port);
|
|
|
|
void UDP_Close (UDPsocket sock);
|
|
|
|
int UDP_Bind (UDPsocket sock, const int channel);
|
|
void UDP_Unbind (UDPsocket sock, const int channel);
|
|
|
|
IPaddress* UDP_GetPeerAddress (UDPsocket sock, const int channel);
|
|
|
|
/* ======================================================= */
|
|
int channel (void) const
|
|
{
|
|
return m_channel;
|
|
}
|
|
|
|
UDPsocket get (const size_t idx) const
|
|
{
|
|
return m_socks.at (idx);
|
|
}
|
|
|
|
std::string toString (void);
|
|
};
|