60e282929f
I'm trying to merge UDPpacketVBuffer and SafeUDPpacketV. Seems pretty messy so far... hopefully this is fruitful.
58 lines
956 B
C++
58 lines
956 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <SDL_net.h>
|
|
|
|
#define DEFAULT_MAX_PACKET_SIZE 512
|
|
|
|
class
|
|
UDPbase
|
|
{
|
|
int mChannel;
|
|
IPaddress mIPAddress;
|
|
void
|
|
CloseAllSockets (void);
|
|
|
|
protected:
|
|
std::vector<UDPsocket> UDPsocks;
|
|
public:
|
|
UDPbase (const char *host, const Uint16 port);
|
|
UDPbase (const char *host, const Uint16 port, const int channel);
|
|
~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
|
|
getChannel (void) const
|
|
{
|
|
return
|
|
mChannel;
|
|
}
|
|
UDPsocket
|
|
getSocket (const size_t idx) const
|
|
{
|
|
return
|
|
UDPsocks.
|
|
at (idx);
|
|
}
|
|
|
|
std::string
|
|
toString (void);
|
|
};
|