egra: cosmetix
[iv.d.git] / sdl2 / net.d
blob13b0bf24581071a73261f9b5ede079e791d9f819
1 /*
3 Boost Software License - Version 1.0 - August 17th, 2003
5 Permission is hereby granted, free of charge, to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license (the "Software") to use, reproduce, display, distribute,
8 execute, and transmit the Software, and to prepare derivative works of the
9 Software, and to permit third-parties to whom the Software is furnished to
10 do so, all subject to the following:
12 The copyright notices in the Software and this entire statement, including
13 the above license grant, this restriction and the following disclaimer,
14 must be included in all copies of the Software, in whole or in part, and
15 all derivative works of the Software, unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
28 module iv.sdl2.net /*is aliced*/;
29 pragma(lib, "SDL2_net");
31 import iv.sdl2.sdl;
33 alias SDLNet_Version = SDL_version;
35 enum : ubyte {
36 SDL_NET_MAJOR_VERSION = 2,
37 SDL_NET_MINOR_VERSION = 0,
38 SDL_NET_PATCHLEVEL = 0,
41 void SDL_NET_VERSION(SDL_version* X) {
42 X.major = SDL_NET_MAJOR_VERSION;
43 X.minor = SDL_NET_MINOR_VERSION;
44 X.patch = SDL_NET_PATCHLEVEL;
47 struct IPaddress {
48 uint host;
49 ushort port;
52 enum {
53 INADDR_ANY = 0x00000000,
54 INADDR_NONE = 0xFFFFFFFF,
55 INADDR_LOOPBACK = 0x7f000001,
56 INADDR_BROADCAST = 0xFFFFFFFF,
59 alias TCPsocket = void*;
61 enum SDLNET_MAX_UDPCHANNELS = 32;
62 enum SDLNET_MAX_UDPADRESSES = 4;
64 alias UDPsocket = void*;
66 struct UDPpacket {
67 int channel;
68 ubyte* data;
69 int len;
70 int maxlen;
71 int status;
72 IPaddress address;
75 struct _SDLNet_SocketSet;
76 alias _SDLNet_SocketSet* SDLNet_SocketSet;
78 struct _SDLNet_GenericSocket {
79 int ready;
81 alias SDLNet_GenericSocket = _SDLNet_GenericSocket*;
83 nothrow @nogc {
84 int SDLNet_TCP_AddSocket (SDLNet_SocketSet set, void* sock) {
85 return SDLNet_AddSocket(set, cast(SDLNet_GenericSocket)sock );
87 alias SDLNet_UDP_AddSocket = SDLNet_TCP_AddSocket;
89 int SDLNet_TCP_DelSocket(SDLNet_SocketSet set, void* sock) {
90 return SDLNet_DelSocket(set, cast(SDLNet_GenericSocket)sock );
92 alias SDLNet_UDP_DelSocket = SDLNet_TCP_DelSocket;
94 bool SDLNet_SocketReady(void* sock) {
95 return (sock && (cast(SDLNet_GenericSocket)sock).ready != 0);
99 extern(C) @nogc nothrow {
100 const(SDLNet_Version)* SDLNet_Linked_Version ();
101 int SDLNet_Init ();
102 void SDLNet_Quit ();
103 int SDLNet_ResolveHost (IPaddress*, const(char)*, ushort);
104 const(char)* SDLNet_ResolveIP (const(IPaddress)*);
105 int SDLNet_GetLocalAddresses (IPaddress*, int);
106 TCPsocket SDLNet_TCP_Open (IPaddress*);
107 TCPsocket SDLNet_TCP_Accept (TCPsocket);
108 IPaddress* SDLNet_TCP_GetPeerAddress (TCPsocket);
109 int SDLNet_TCP_Send (TCPsocket, const(void)*, int);
110 int SDLNet_TCP_Recv (TCPsocket, void*, int);
111 void SDLNet_TCP_Close (TCPsocket);
112 UDPpacket* SDLNet_AllocPacket (int);
113 int SDLNet_ResizePacket (UDPpacket*, int);
114 void SDLNet_FreePacket (UDPpacket*);
115 UDPpacket** SDLNet_AllocPacketV (int, int);
116 void SDLNet_FreePacketV (UDPpacket**);
117 UDPsocket SDLNet_UDP_Open (ushort);
118 void SDLNet_UDP_SetPacketLoss (UDPsocket, int);
119 int SDLNet_UDP_Bind (UDPsocket, int, const(IPaddress)*);
120 void SDLNet_UDP_Unbind (UDPsocket, int);
121 IPaddress* SDLNet_UDP_GetPeerAddress (UDPsocket, int);
122 int SDLNet_UDP_SendV (UDPsocket, UDPpacket**, int);
123 int SDLNet_UDP_Send (UDPsocket, int, UDPpacket*);
124 int SDLNet_UDP_RecvV (UDPsocket, UDPpacket**);
125 int SDLNet_UDP_Recv (UDPsocket, UDPpacket*);
126 void SDLNet_UDP_Close (UDPsocket);
127 SDLNet_SocketSet SDLNet_AllocSocketSet (int);
128 int SDLNet_AddSocket (SDLNet_SocketSet, SDLNet_GenericSocket);
129 int SDLNet_DelSocket (SDLNet_SocketSet, SDLNet_GenericSocket);
130 int SDLNet_CheckSockets (SDLNet_SocketSet, uint);
131 void SDLNet_FreeSocketSet (SDLNet_SocketSet);
132 void SDLNet_SetError (const(char)* fmt, ...);
133 const(char)* SDLNet_GetError ();