HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_NetPacket Class Reference

#include <UT_NetPacket.h>

Public Types

enum  { PacketCompress = 0x01, PacketCrypt = 0x02 }
 

Public Member Functions

 UT_NetPacket (unsigned write_bufsize=4096, unsigned read_bufsize=0)
 
 ~UT_NetPacket ()
 
int64 getMemoryUsage (bool inclusive) const
 
int writeData (UT_NetSocket &sock, const void *data, unsigned len)
 
int writeData (UT_NetSocket &sock, const char *data)
 
bool write (UT_NetSocket &sock, const UT_WorkBuffer &data)
 
int flush (UT_NetSocket &sock)
 
int readPacketLength (UT_NetSocket &sock, int *timeout_ms=NULL)
 
int readPacketLength (UT_NetSocket &sock, int *timeout_ms, int &status)
 
int readPacketData (UT_NetSocket &sock, void *buf, unsigned len, int *timeout_ms=NULL)
 
int readPacketData (UT_NetSocket &sock, UT_WorkBuffer &buf, unsigned int len, int *timeout_ms=NULL)
 
int readPacketData (UT_NetSocket &sock, void *buf, unsigned len, int *timeout_ms, int &status)
 
int readPacketData (UT_NetSocket &sock, UT_WorkBuffer &buf, unsigned int len, int *timeout_ms, int &status)
 
voidreadPacket (UT_NetSocket &sock, unsigned &len, int timeout_ms, int &status)
 
voidreadPacket (UT_NetSocket &sock, unsigned &len, int timeout_ms=-1)
 
unsigned readPacket (UT_NetSocket &sock, void *data, unsigned size, int timeout_ms, int &status)
 
unsigned readPacket (UT_NetSocket &sock, void *data, unsigned size, int timeout_ms=-1)
 
bool read (UT_NetSocket &sock, UT_WorkBuffer &wbuf, unsigned len, int timeout=-1)
 
bool read (UT_NetSocket &sock, UT_WorkBuffer &wbuf, unsigned len, int timeout, int &status)
 
unsigned readPacket (UT_NetSocket &sock, UT_WorkBuffer &wbuf, int timeout_ms=-1)
 
unsigned readPacket (UT_NetSocket &sock, UT_WorkBuffer &wbuf, int timeout_ms, int &status)
 
void setFlag (unsigned flag)
 
void clearFlag (unsigned flag)
 
int getFlag (unsigned flag) const
 
unsigned getDataSize () const
 
void limitDataSize (unsigned maxsize=4096)
 
voidsteal ()
 

Static Public Member Functions

static UT_NetSocketacceptClient (UT_NetSocket &server, int blocking=1, int timeout=10)
 
static const char * getHost ()
 
static const char * getUserHost ()
 
static int matchIPMask (const char *mask, const char *address, UT_NetSocket *socket)
 
static bool matchServerClientIPs (const UT_IpAddressV4 &server, const UT_IpAddressV4 &client, const char *mask_pattern)
 
static UT_NetSocketconnectToServer (const char *host=0, int port=-1, int blocking=1, int timeout=5)
 
static int getDefaultServerPort ()
 
static void disconnectFromServer (UT_NetSocket *socket)
 

Detailed Description

Use NET_PacketSocket instead of UT_NetPacket. UT_NetPacket has a lot of short comings when something unexpected occurs. UT_NetPacket also doesn't support async very well. Additionally, its very difficult to get proper error information when something goes wrong.

Definition at line 38 of file UT_NetPacket.h.

Member Enumeration Documentation

anonymous enum
Enumerator
PacketCompress 
PacketCrypt 

Definition at line 106 of file UT_NetPacket.h.

Constructor & Destructor Documentation

UT_NetPacket::UT_NetPacket ( unsigned  write_bufsize = 4096,
unsigned  read_bufsize = 0 
)
explicit
UT_NetPacket::~UT_NetPacket ( )

Member Function Documentation

static UT_NetSocket* UT_NetPacket::acceptClient ( UT_NetSocket server,
int  blocking = 1,
int  timeout = 10 
)
static
void UT_NetPacket::clearFlag ( unsigned  flag)
inline

Definition at line 180 of file UT_NetPacket.h.

static UT_NetSocket* UT_NetPacket::connectToServer ( const char *  host = 0,
int  port = -1,
int  blocking = 1,
int  timeout = 5 
)
static
static void UT_NetPacket::disconnectFromServer ( UT_NetSocket socket)
static
int UT_NetPacket::flush ( UT_NetSocket sock)
unsigned UT_NetPacket::getDataSize ( ) const
inline

Definition at line 183 of file UT_NetPacket.h.

static int UT_NetPacket::getDefaultServerPort ( )
static
int UT_NetPacket::getFlag ( unsigned  flag) const
inline

Definition at line 181 of file UT_NetPacket.h.

static const char* UT_NetPacket::getHost ( )
static
int64 UT_NetPacket::getMemoryUsage ( bool  inclusive) const
static const char* UT_NetPacket::getUserHost ( )
static
void UT_NetPacket::limitDataSize ( unsigned  maxsize = 4096)
inline

Definition at line 184 of file UT_NetPacket.h.

static int UT_NetPacket::matchIPMask ( const char *  mask,
const char *  address,
UT_NetSocket socket 
)
static
static bool UT_NetPacket::matchServerClientIPs ( const UT_IpAddressV4 server,
const UT_IpAddressV4 client,
const char *  mask_pattern 
)
static
bool UT_NetPacket::read ( UT_NetSocket sock,
UT_WorkBuffer wbuf,
unsigned  len,
int  timeout = -1 
)
bool UT_NetPacket::read ( UT_NetSocket sock,
UT_WorkBuffer wbuf,
unsigned  len,
int  timeout,
int status 
)
void * UT_NetPacket::readPacket ( UT_NetSocket sock,
unsigned &  len,
int  timeout_ms,
int status 
)
inline

Definition at line 214 of file UT_NetPacket.h.

void * UT_NetPacket::readPacket ( UT_NetSocket sock,
unsigned &  len,
int  timeout_ms = -1 
)
inline

Definition at line 231 of file UT_NetPacket.h.

unsigned UT_NetPacket::readPacket ( UT_NetSocket sock,
void data,
unsigned  size,
int  timeout_ms,
int status 
)
inline

Definition at line 239 of file UT_NetPacket.h.

unsigned UT_NetPacket::readPacket ( UT_NetSocket sock,
void data,
unsigned  size,
int  timeout_ms = -1 
)
inline

Definition at line 254 of file UT_NetPacket.h.

unsigned UT_NetPacket::readPacket ( UT_NetSocket sock,
UT_WorkBuffer wbuf,
int  timeout_ms = -1 
)
unsigned UT_NetPacket::readPacket ( UT_NetSocket sock,
UT_WorkBuffer wbuf,
int  timeout_ms,
int status 
)
int UT_NetPacket::readPacketData ( UT_NetSocket sock,
void buf,
unsigned  len,
int timeout_ms = NULL 
)
int UT_NetPacket::readPacketData ( UT_NetSocket sock,
UT_WorkBuffer buf,
unsigned int  len,
int timeout_ms = NULL 
)
int UT_NetPacket::readPacketData ( UT_NetSocket sock,
void buf,
unsigned  len,
int timeout_ms,
int status 
)
int UT_NetPacket::readPacketData ( UT_NetSocket sock,
UT_WorkBuffer buf,
unsigned int  len,
int timeout_ms,
int status 
)
int UT_NetPacket::readPacketLength ( UT_NetSocket sock,
int timeout_ms = NULL 
)
int UT_NetPacket::readPacketLength ( UT_NetSocket sock,
int timeout_ms,
int status 
)
void UT_NetPacket::setFlag ( unsigned  flag)
inline

Definition at line 179 of file UT_NetPacket.h.

void* UT_NetPacket::steal ( )
inline

Definition at line 189 of file UT_NetPacket.h.

bool UT_NetPacket::write ( UT_NetSocket sock,
const UT_WorkBuffer data 
)
int UT_NetPacket::writeData ( UT_NetSocket sock,
const void data,
unsigned  len 
)
int UT_NetPacket::writeData ( UT_NetSocket sock,
const char *  data 
)
inline

Definition at line 116 of file UT_NetPacket.h.


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