zenilib: zenilib/jni/external/sdl_net/SDL/SDL_net.h File Reference

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Macros | Typedefs | Functions
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; \
}
SDL_NET_PATCHLEVEL
#define SDL_NET_PATCHLEVEL
Definition: SDL_net.h:61
SDL_NET_MINOR_VERSION
#define SDL_NET_MINOR_VERSION
Definition: SDL_net.h:60
SDL_NET_MAJOR_VERSION
#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_Read16 | ( |  | areap | ) | _SDLNet_Read16(areap)

Definition at line 380 of file SDL_net.h.

Referenced by HandleServerData(), Zeni::iptoa(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), SDLNet_ResolveHost(), SDLNet_UDP_Open(), and Zeni::unserialize().

#define SDLNet_Read32 | ( |  | areap | ) | _SDLNet_Read32(areap)

Definition at line 381 of file SDL_net.h.

Referenced by HandleServerData(), Zeni::iptoa(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), and Zeni::unserialize().

#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_GenericSocket * SDLNet_GenericSocket

typedef struct _SDLNet_SocketSet* SDLNet_SocketSet

Definition at line 298 of file SDL_net.h.

typedef SDL_version SDLNet_version

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 | ) |

Definition at line 51 of file SDLnetUDP.c.

References UDPpacket::data, error, malloc, UDPpacket::maxlen, NULL, SDLNet_FreePacket(), and SDLNet_SetError().

Referenced by SDLNet_AllocPacketV().

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
| ) |  |

Definition at line 110 of file SDLnetselect.c.

References i, NULL, SDLNet_GetLastError(), SDLNet_SetLastError(), and SOCKET.

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

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 void SDLCALL SDLNet_SetError | ( | const char * | fmt,
|  |  | ...
| ) |  |

Definition at line 65 of file SDLnet.c.

References errorbuf, SDL_SetError(), and SDL_vsnprintf().

Referenced by SDLNet_AddSocket(), SDLNet_AllocPacket(), SDLNet_AllocPacketV(), SDLNet_DelSocket(), SDLNet_Init(), SDLNet_TCP_Accept(), SDLNet_TCP_Open(), SDLNet_TCP_Recv(), SDLNet_TCP_Send(), SDLNet_UDP_Bind(), SDLNet_UDP_Open(), SDLNet_UDP_SendV(), and ValidChannel().

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().

DECLSPEC void SDLCALL SDLNet_TCP_Close | ( | TCPsocket | sock | ) |

Definition at line 289 of file SDLnetTCP.c.

References closesocket, free, INVALID_SOCKET, and NULL.

Referenced by cleanup(), HandleClient(), HandleServer(), main(), SDLNet_TCP_Accept(), SDLNet_TCP_Open(), Zeni::TCP_Socket::TCP_Socket(), Zeni::TCP_Listener::~TCP_Listener(), 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 TCPsocket SDLCALL SDLNet_TCP_Open | ( | IPaddress * | ip | ) |

Definition at line 46 of file SDLnetTCP.c.

References IPaddress::host, INADDR_ANY, INADDR_NONE, INVALID_SOCKET, malloc, memset, NULL, IPaddress::port, SDLNet_SetError(), SDLNet_TCP_Close(), sock, and SOCKET_ERROR.

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

DECLSPEC int SDLCALL SDLNet_TCP_Recv | ( | TCPsocket | sock,
|  | void * | data,
|  | int | maxlen
| ) |  |

Definition at line 269 of file SDLnetTCP.c.

References SDLNet_GetLastError(), SDLNet_SetError(), and SDLNet_SetLastError().

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

DECLSPEC int SDLCALL SDLNet_TCP_Send | ( | TCPsocket | sock,
|  | const void * | data,
|  | int | len
| ) |  |

Definition at line 236 of file SDLnetTCP.c.

References SDLNet_GetLastError(), SDLNet_SetError(), and SDLNet_SetLastError().

Referenced by HandleClient(), HandleServer(), SendHello(), SendNew(), and Zeni::TCP_Socket::try_send().

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
| ) |  |

Definition at line 256 of file SDLnetUDP.c.

References NULL, SDLNET_MAX_UDPADDRESSES, SDLNET_MAX_UDPCHANNELS, SDLNet_SetError(), and ValidChannel().

Referenced by HandleServerData().

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 UDPsocket SDLCALL SDLNet_UDP_Open | ( | Uint16 | port | ) |

Definition at line 139 of file SDLnetUDP.c.

References INADDR_ANY, INVALID_SOCKET, malloc, memset, NULL, SDLNet_Read16, SDLNet_SetError(), SDLNet_UDP_Close(), sock, and SOCKET_ERROR.

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

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_RecvV | ( | UDPsocket | sock,
|  | UDPpacket ** | packets
| ) |  |

Definition at line 439 of file SDLnetUDP.c.

References UDPpacket::address, UDPpacket::channel, UDPpacket::data, IPaddress::host, i, j, UDPpacket::len, UDPpacket::maxlen, NULL, IPaddress::port, SDLNET_MAX_UDPCHANNELS, SocketReady(), and UDPpacket::status.

Referenced by HandleClient(), and SDLNet_UDP_Recv().

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
| ) |  |

Definition at line 326 of file SDLnetUDP.c.

References UDPpacket::address, UDPpacket::channel, UDPpacket::data, IPaddress::host, i, j, UDPpacket::len, NULL, IPaddress::port, SDLNet_SetError(), and UDPpacket::status.

Referenced by SDLNet_UDP_Send().

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().