zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_net.h File Reference
#include "SDL/SDL.h"
#include "SDL/SDL_endian.h"
#include "SDL/SDL_version.h"
#include "SDL/begin_code.h"
#include "SDL/close_code.h"

Go to the source code of this file.

Classes

struct  _SDLNet_GenericSocket
 
struct  IPaddress
 
struct  UDPpacket
 

Macros

#define INADDR_ANY   0x00000000
 
#define INADDR_BROADCAST   0xFFFFFFFF
 
#define INADDR_LOOPBACK   0x7f000001
 
#define INADDR_NONE   0xFFFFFFFF
 
#define SDL_DATA_ALIGNED   0
 
#define SDL_NET_MAJOR_VERSION   2
 
#define SDL_NET_MINOR_VERSION   0
 
#define SDL_NET_PATCHLEVEL   0
 
#define SDL_NET_VERSION(X)
 
#define SDLNET_MAX_UDPADDRESSES   4
 
#define SDLNET_MAX_UDPCHANNELS   32
 
#define SDLNet_Read16(areap)   _SDLNet_Read16(areap)
 
#define SDLNet_Read32(areap)   _SDLNet_Read32(areap)
 
#define SDLNet_SocketReady(sock)   _SDLNet_SocketReady((SDLNet_GenericSocket)(sock))
 
#define SDLNet_Write16(value, areap)   _SDLNet_Write16(value, areap)
 
#define SDLNet_Write32(value, areap)   _SDLNet_Write32(value, areap)
 

Typedefs

typedef struct
_SDLNet_GenericSocket
SDLNet_GenericSocket
 
typedef struct _SDLNet_SocketSet * SDLNet_SocketSet
 
typedef SDL_version SDLNet_version
 
typedef struct _TCPsocket * TCPsocket
 
typedef struct _UDPsocket * UDPsocket
 

Functions

static __inline__ Uint16 _SDLNet_Read16 (const void *areap)
 
static __inline__ Uint32 _SDLNet_Read32 (const void *areap)
 
static __inline__ int _SDLNet_SocketReady (SDLNet_GenericSocket sock)
 
static __inline__ void _SDLNet_Write16 (Uint16 value, void *areap)
 
static __inline__ void _SDLNet_Write32 (Uint32 value, void *areap)
 
DECLSPEC int SDLCALL SDLNet_AddSocket (SDLNet_SocketSet set, SDLNet_GenericSocket sock)
 
DECLSPEC UDPpacket *SDLCALL SDLNet_AllocPacket (int size)
 
DECLSPEC UDPpacket **SDLCALL SDLNet_AllocPacketV (int howmany, int size)
 
DECLSPEC SDLNet_SocketSet SDLCALL SDLNet_AllocSocketSet (int maxsockets)
 
DECLSPEC int SDLCALL SDLNet_CheckSockets (SDLNet_SocketSet set, Uint32 timeout)
 
DECLSPEC int SDLCALL SDLNet_DelSocket (SDLNet_SocketSet set, SDLNet_GenericSocket sock)
 
DECLSPEC void SDLCALL SDLNet_FreePacket (UDPpacket *packet)
 
DECLSPEC void SDLCALL SDLNet_FreePacketV (UDPpacket **packetV)
 
DECLSPEC void SDLCALL SDLNet_FreeSocketSet (SDLNet_SocketSet set)
 
DECLSPEC const char *SDLCALL SDLNet_GetError (void)
 
DECLSPEC int SDLCALL SDLNet_GetLocalAddresses (IPaddress *addresses, int maxcount)
 
DECLSPEC int SDLCALL SDLNet_Init (void)
 
DECLSPEC const SDLNet_version
*SDLCALL 
SDLNet_Linked_Version (void)
 
DECLSPEC void SDLCALL SDLNet_Quit (void)
 
DECLSPEC int SDLCALL SDLNet_ResizePacket (UDPpacket *packet, int newsize)
 
DECLSPEC int SDLCALL SDLNet_ResolveHost (IPaddress *address, const char *host, Uint16 port)
 
DECLSPEC const char *SDLCALL SDLNet_ResolveIP (const IPaddress *ip)
 
DECLSPEC void SDLCALL SDLNet_SetError (const char *fmt,...)
 
DECLSPEC TCPsocket SDLCALL SDLNet_TCP_Accept (TCPsocket server)
 
static __inline__ int SDLNet_TCP_AddSocket (SDLNet_SocketSet set, TCPsocket sock)
 
DECLSPEC void SDLCALL SDLNet_TCP_Close (TCPsocket sock)
 
static __inline__ int SDLNet_TCP_DelSocket (SDLNet_SocketSet set, TCPsocket sock)
 
DECLSPEC IPaddress *SDLCALL SDLNet_TCP_GetPeerAddress (TCPsocket sock)
 
DECLSPEC TCPsocket SDLCALL SDLNet_TCP_Open (IPaddress *ip)
 
DECLSPEC int SDLCALL SDLNet_TCP_Recv (TCPsocket sock, void *data, int maxlen)
 
DECLSPEC int SDLCALL SDLNet_TCP_Send (TCPsocket sock, const void *data, int len)
 
static __inline__ int SDLNet_UDP_AddSocket (SDLNet_SocketSet set, UDPsocket sock)
 
DECLSPEC int SDLCALL SDLNet_UDP_Bind (UDPsocket sock, int channel, const IPaddress *address)
 
DECLSPEC void SDLCALL SDLNet_UDP_Close (UDPsocket sock)
 
static __inline__ int SDLNet_UDP_DelSocket (SDLNet_SocketSet set, UDPsocket sock)
 
DECLSPEC IPaddress *SDLCALL SDLNet_UDP_GetPeerAddress (UDPsocket sock, int channel)
 
DECLSPEC UDPsocket SDLCALL SDLNet_UDP_Open (Uint16 port)
 
DECLSPEC int SDLCALL SDLNet_UDP_Recv (UDPsocket sock, UDPpacket *packet)
 
DECLSPEC int SDLCALL SDLNet_UDP_RecvV (UDPsocket sock, UDPpacket **packets)
 
DECLSPEC int SDLCALL SDLNet_UDP_Send (UDPsocket sock, int channel, UDPpacket *packet)
 
DECLSPEC int SDLCALL SDLNet_UDP_SendV (UDPsocket sock, UDPpacket **packets, int npackets)
 
DECLSPEC void SDLCALL SDLNet_UDP_SetPacketLoss (UDPsocket sock, int percent)
 
DECLSPEC void SDLCALL SDLNet_UDP_Unbind (UDPsocket sock, int channel)
 

Macro Definition Documentation

#define INADDR_ANY   0x00000000

Definition at line 102 of file SDL_net.h.

Referenced by SDLNet_ResolveHost(), SDLNet_TCP_Open(), and SDLNet_UDP_Open().

#define INADDR_BROADCAST   0xFFFFFFFF

Definition at line 111 of file SDL_net.h.

#define INADDR_LOOPBACK   0x7f000001

Definition at line 108 of file SDL_net.h.

#define INADDR_NONE   0xFFFFFFFF

Definition at line 105 of file SDL_net.h.

Referenced by main(), SDLNet_ResolveHost(), and SDLNet_TCP_Open().

#define SDL_DATA_ALIGNED   0

Definition at line 372 of file SDL_net.h.

#define SDL_NET_MAJOR_VERSION   2

Definition at line 59 of file SDL_net.h.

#define SDL_NET_MINOR_VERSION   0

Definition at line 60 of file SDL_net.h.

#define SDL_NET_PATCHLEVEL   0

Definition at line 61 of file SDL_net.h.

#define SDL_NET_VERSION (   X)
Value:
{ \
(X)->major = SDL_NET_MAJOR_VERSION; \
(X)->minor = SDL_NET_MINOR_VERSION; \
(X)->patch = SDL_NET_PATCHLEVEL; \
}
#define SDL_NET_PATCHLEVEL
Definition: SDL_net.h:61
#define SDL_NET_MINOR_VERSION
Definition: SDL_net.h:60
#define SDL_NET_MAJOR_VERSION
Definition: SDL_net.h:59

Definition at line 66 of file SDL_net.h.

Referenced by SDLNet_Linked_Version().

#define SDLNET_MAX_UDPADDRESSES   4

Definition at line 180 of file SDL_net.h.

Referenced by SDLNet_UDP_Bind().

#define SDLNET_MAX_UDPCHANNELS   32

Definition at line 178 of file SDL_net.h.

Referenced by SDLNet_UDP_Bind(), SDLNet_UDP_RecvV(), SDLNet_UDP_Unbind(), and ValidChannel().

#define SDLNet_Read32 (   areap)    _SDLNet_Read32(areap)
#define SDLNet_SocketReady (   sock)    _SDLNet_SocketReady((SDLNet_GenericSocket)(sock))

Definition at line 347 of file SDL_net.h.

Referenced by HandleNet(), and main().

#define SDLNet_Write16 (   value,
  areap 
)    _SDLNet_Write16(value, areap)

Definition at line 376 of file SDL_net.h.

Referenced by Zeni::serialize(), and Zeni::TCP_Listener::TCP_Listener().

#define SDLNet_Write32 (   value,
  areap 
)    _SDLNet_Write32(value, areap)

Definition at line 377 of file SDL_net.h.

Referenced by Zeni::serialize().

Typedef Documentation

typedef struct _SDLNet_SocketSet* SDLNet_SocketSet

Definition at line 298 of file SDL_net.h.

Definition at line 46 of file SDL_net.h.

typedef struct _TCPsocket* TCPsocket

Definition at line 131 of file SDL_net.h.

typedef struct _UDPsocket* UDPsocket

Definition at line 182 of file SDL_net.h.

Function Documentation

static __inline__ Uint16 _SDLNet_Read16 ( const void areap)
static

Definition at line 395 of file SDL_net.h.

References SDL_SwapBE16.

static __inline__ Uint32 _SDLNet_Read32 ( const void areap)
static

Definition at line 400 of file SDL_net.h.

References SDL_SwapBE32.

static __inline__ int _SDLNet_SocketReady ( SDLNet_GenericSocket  sock)
static

Definition at line 348 of file SDL_net.h.

References NULL, and _SDLNet_GenericSocket::ready.

static __inline__ void _SDLNet_Write16 ( Uint16  value,
void areap 
)
static

Definition at line 385 of file SDL_net.h.

References SDL_SwapBE16.

static __inline__ void _SDLNet_Write32 ( Uint32  value,
void areap 
)
static

Definition at line 390 of file SDL_net.h.

References SDL_SwapBE32.

DECLSPEC int SDLCALL SDLNet_AddSocket ( SDLNet_SocketSet  set,
SDLNet_GenericSocket  sock 
)

Definition at line 68 of file SDLnetselect.c.

References NULL, and SDLNet_SetError().

Referenced by SDLNet_TCP_AddSocket(), and SDLNet_UDP_AddSocket().

DECLSPEC UDPpacket* SDLCALL SDLNet_AllocPacket ( int  size)
DECLSPEC UDPpacket** SDLCALL SDLNet_AllocPacketV ( int  howmany,
int  size 
)

Definition at line 98 of file SDLnetUDP.c.

References i, malloc, NULL, SDLNet_AllocPacket(), SDLNet_FreePacketV(), and SDLNet_SetError().

Referenced by main().

DECLSPEC SDLNet_SocketSet SDLCALL SDLNet_AllocSocketSet ( int  maxsockets)

Definition at line 44 of file SDLnetselect.c.

References free, i, malloc, and NULL.

Referenced by main(), and Zeni::TCP_Socket::TCP_Socket().

DECLSPEC int SDLCALL SDLNet_CheckSockets ( SDLNet_SocketSet  set,
Uint32  timeout 
)
DECLSPEC int SDLCALL SDLNet_DelSocket ( SDLNet_SocketSet  set,
SDLNet_GenericSocket  sock 
)

Definition at line 81 of file SDLnetselect.c.

References i, NULL, and SDLNet_SetError().

Referenced by SDLNet_TCP_DelSocket(), and SDLNet_UDP_DelSocket().

DECLSPEC void SDLCALL SDLNet_FreePacket ( UDPpacket packet)

Definition at line 85 of file SDLnetUDP.c.

References UDPpacket::data, and free.

Referenced by SDLNet_AllocPacket(), and SDLNet_FreePacketV().

DECLSPEC void SDLCALL SDLNet_FreePacketV ( UDPpacket **  packetV)

Definition at line 121 of file SDLnetUDP.c.

References free, i, and SDLNet_FreePacket().

Referenced by cleanup(), and SDLNet_AllocPacketV().

DECLSPEC void SDLCALL SDLNet_FreeSocketSet ( SDLNet_SocketSet  set)

Definition at line 156 of file SDLnetselect.c.

References free.

Referenced by cleanup(), Zeni::TCP_Socket::TCP_Socket(), and Zeni::TCP_Socket::~TCP_Socket().

DECLSPEC const char* SDLCALL SDLNet_GetError ( void  )

Definition at line 76 of file SDLnet.c.

References errorbuf, and SDL_GetError().

Referenced by main(), and print_errors().

DECLSPEC int SDLCALL SDLNet_GetLocalAddresses ( IPaddress addresses,
int  maxcount 
)

Definition at line 187 of file SDLnet.c.

References closesocket, DWORD(), free, IPaddress::host, INVALID_SOCKET, malloc, NULL, IPaddress::port, realloc, sock, and SOCKET.

Referenced by main().

DECLSPEC int SDLCALL SDLNet_Init ( void  )

Definition at line 86 of file SDLnet.c.

References int, SDLNet_SetError(), and SDLNet_started.

Referenced by main().

DECLSPEC const SDLNet_version* SDLCALL SDLNet_Linked_Version ( void  )

Definition at line 33 of file SDLnet.c.

References SDL_NET_VERSION.

DECLSPEC void SDLCALL SDLNet_Quit ( void  )

Definition at line 110 of file SDLnet.c.

References int, SDLNet_started, and SOCKET_ERROR.

Referenced by cleanup().

DECLSPEC int SDLCALL SDLNet_ResizePacket ( UDPpacket packet,
int  newsize 
)

Definition at line 73 of file SDLnetUDP.c.

References UDPpacket::data, free, malloc, UDPpacket::maxlen, and NULL.

DECLSPEC int SDLCALL SDLNet_ResolveHost ( IPaddress address,
const char *  host,
Uint16  port 
)

Definition at line 138 of file SDLnet.c.

References IPaddress::host, INADDR_ANY, INADDR_NONE, memcpy, NULL, IPaddress::port, and SDLNet_Read16.

Referenced by main(), and Zeni::Net::resolve_host().

DECLSPEC const char* SDLCALL SDLNet_ResolveIP ( const IPaddress ip)

Definition at line 173 of file SDLnet.c.

References IPaddress::host, and NULL.

Referenced by main(), and Zeni::Net::reverse_lookup().

DECLSPEC TCPsocket SDLCALL SDLNet_TCP_Accept ( TCPsocket  server)

Definition at line 166 of file SDLnetTCP.c.

References INVALID_SOCKET, malloc, NULL, SDLNet_SetError(), SDLNet_TCP_Close(), and sock.

Referenced by Zeni::TCP_Listener::accept(), and HandleServer().

static __inline__ int SDLNet_TCP_AddSocket ( SDLNet_SocketSet  set,
TCPsocket  sock 
)
static

Definition at line 313 of file SDL_net.h.

References SDLNet_AddSocket().

Referenced by HandleServer(), main(), and Zeni::TCP_Socket::TCP_Socket().

static __inline__ int SDLNet_TCP_DelSocket ( SDLNet_SocketSet  set,
TCPsocket  sock 
)
static

Definition at line 325 of file SDL_net.h.

References SDLNet_DelSocket().

Referenced by HandleClient(), HandleServer(), and Zeni::TCP_Socket::~TCP_Socket().

DECLSPEC IPaddress* SDLCALL SDLNet_TCP_GetPeerAddress ( TCPsocket  sock)

Definition at line 223 of file SDLnetTCP.c.

References NULL.

Referenced by HandleServer(), and Zeni::TCP_Socket::peer_address().

DECLSPEC int SDLCALL SDLNet_TCP_Recv ( TCPsocket  sock,
void data,
int  maxlen 
)
DECLSPEC int SDLCALL SDLNet_TCP_Send ( TCPsocket  sock,
const void data,
int  len 
)
static __inline__ int SDLNet_UDP_AddSocket ( SDLNet_SocketSet  set,
UDPsocket  sock 
)
static

Definition at line 317 of file SDL_net.h.

References SDLNet_AddSocket().

Referenced by main().

DECLSPEC int SDLCALL SDLNet_UDP_Bind ( UDPsocket  sock,
int  channel,
const IPaddress address 
)
DECLSPEC void SDLCALL SDLNet_UDP_Close ( UDPsocket  sock)

Definition at line 515 of file SDLnetUDP.c.

References closesocket, free, INVALID_SOCKET, and NULL.

Referenced by cleanup(), SDLNet_UDP_Open(), and Zeni::UDP_Socket::~UDP_Socket().

static __inline__ int SDLNet_UDP_DelSocket ( SDLNet_SocketSet  set,
UDPsocket  sock 
)
static

Definition at line 329 of file SDL_net.h.

References SDLNet_DelSocket().

DECLSPEC IPaddress* SDLCALL SDLNet_UDP_GetPeerAddress ( UDPsocket  sock,
int  channel 
)

Definition at line 298 of file SDLnetUDP.c.

References NULL, and ValidChannel().

Referenced by Zeni::UDP_Socket::peer_address(), and SendHello().

DECLSPEC int SDLCALL SDLNet_UDP_Recv ( UDPsocket  sock,
UDPpacket packet 
)

Definition at line 504 of file SDLnetUDP.c.

References NULL, packets, and SDLNet_UDP_RecvV().

Referenced by Zeni::UDP_Socket::receive().

DECLSPEC int SDLCALL SDLNet_UDP_Send ( UDPsocket  sock,
int  channel,
UDPpacket packet 
)

Definition at line 399 of file SDLnetUDP.c.

References UDPpacket::channel, and SDLNet_UDP_SendV().

Referenced by Zeni::UDP_Socket::send(), and SendBuf().

DECLSPEC int SDLCALL SDLNet_UDP_SendV ( UDPsocket  sock,
UDPpacket **  packets,
int  npackets 
)
DECLSPEC void SDLCALL SDLNet_UDP_SetPacketLoss ( UDPsocket  sock,
int  percent 
)

Definition at line 220 of file SDLnetUDP.c.

References NULL.

DECLSPEC void SDLCALL SDLNet_UDP_Unbind ( UDPsocket  sock,
int  channel 
)

Definition at line 287 of file SDLnetUDP.c.

References SDLNET_MAX_UDPCHANNELS.

Referenced by HandleServerData().