sdl2_net.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. {*
  2. SDL_net: An example cross-platform network library for use with SDL
  3. Copyright (C) 1997-2013 Sam Lantinga <[email protected]>
  4. Copyright (C) 2012 Simeon Maxein <[email protected]>
  5. This software is provided 'as-is', without any express or implied
  6. warranty. In no event will the authors be held liable for any damages
  7. arising from the use of this software.
  8. Permission is granted to anyone to use this software for any purpose,
  9. including commercial applications, and to alter it and redistribute it
  10. freely, subject to the following restrictions:
  11. 1. The origin of this software must not be misrepresented; you must not
  12. claim that you wrote the original software. If you use this software
  13. in a product, an acknowledgment in the product documentation would be
  14. appreciated but is not required.
  15. 2. Altered source versions must be plainly marked as such, and must not be
  16. misrepresented as being the original software.
  17. 3. This notice may not be removed or altered from any source distribution.
  18. *}
  19. unit sdl2_net;
  20. {$INCLUDE jedi.inc}
  21. interface
  22. uses
  23. {$IFDEF FPC}
  24. ctypes,
  25. {$ENDIF}
  26. SDL2;
  27. {$I ctypes.inc}
  28. const
  29. {$IFDEF WINDOWS}
  30. SDLNet_LibName = 'SDL2_net.dll';
  31. {$ENDIF}
  32. {$IFDEF UNIX}
  33. {$IFDEF DARWIN}
  34. SDLNet_LibName = 'libSDL2_net.dylib';
  35. {$ELSE}
  36. {$IFDEF FPC}
  37. SDLNet_LibName = 'libSDL2_net.so';
  38. {$ELSE}
  39. SDLNet_LibName = 'libSDL2_net-2.0.so.0';
  40. {$ENDIF}
  41. {$ENDIF}
  42. {$ENDIF}
  43. {$IFDEF MACOS}
  44. SDLNet_LibName = 'SDL2_net';
  45. {$IFDEF FPC}
  46. {$linklib libSDL2_net}
  47. {$ENDIF}
  48. {$ENDIF}
  49. type
  50. PPSDLNet_Version = ^PSDLNet_Version;
  51. PSDLNet_Version = ^TSDLNet_Version;
  52. TSDLNet_Version = TSDL_Version;
  53. const
  54. {* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *}
  55. SDL_NET_MAJOR_VERSION = 2;
  56. SDL_NET_MINOR_VERSION = 0;
  57. SDL_NET_PATCHLEVEL = 0;
  58. {* This macro can be used to fill a version structure with the compile-time
  59. * version of the SDL_net library.
  60. *}
  61. procedure SDL_NET_VERSION(Out X: TSDL_Version);
  62. {* This function gets the version of the dynamically linked SDL_net library.
  63. it should NOT be used to fill a version structure, instead you should
  64. use the SDL_NET_VERSION() macro.
  65. *}
  66. function SDLNet_Linked_Version: PSDL_Version cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_Linked_Version' {$ENDIF} {$ENDIF};
  67. {* Initialize/Cleanup the network API
  68. SDL must be initialized before calls to functions in this library,
  69. because this library uses utility functions from the SDL library.
  70. *}
  71. function SDLNet_Init(): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_Init' {$ENDIF} {$ENDIF};
  72. procedure SDLNet_Quit() cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_Quit' {$ENDIF} {$ENDIF};
  73. type
  74. {***********************************************************************}
  75. {* IPv4 hostname resolution API *}
  76. {***********************************************************************}
  77. PPIPaddress = ^PIPaddress;
  78. PIPaddress = ^TIPaddress;
  79. TIPaddress = record
  80. host: cuint32; {* 32-bit IPv4 host address *}
  81. port: cuint16; {* 16-bit protocol port *}
  82. end;
  83. {* Resolve a host name and port to an IP address in network form.
  84. If the function succeeds, it will return 0.
  85. If the host couldn't be resolved, the host portion of the returned
  86. address will be INADDR_NONE, and the function will return -1.
  87. If 'host' is NULL, the resolved host will be set to INADDR_ANY.
  88. *}
  89. const
  90. INADDR_ANY = $00000000;
  91. INADDR_NONE = $FFFFFFFF;
  92. INADDR_LOOPBACK = $7f000001;
  93. INADDR_BROADCAST = $FFFFFFFF;
  94. function SDLNet_ResolveHost(address: PIPaddress; const host: PAnsiChar; port: cuint16): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_ResolveHost' {$ENDIF} {$ENDIF};
  95. {* Resolve an ip address to a host name in canonical form.
  96. If the ip couldn't be resolved, this function returns NULL,
  97. otherwise a pointer to a static buffer containing the hostname
  98. is returned. Note that this function is not thread-safe.
  99. *}
  100. function SDLNet_ResolveIP(const ip: PIPaddress): PAnsiChar cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_ResolveIP' {$ENDIF} {$ENDIF};
  101. {* Get the addresses of network interfaces on this system.
  102. This returns the number of addresses saved in 'addresses'
  103. *}
  104. function SDLNet_GetLocalAddresses(addresses: PIPaddress; maxcount: cint): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_GetLocalAddresses' {$ENDIF} {$ENDIF};
  105. {***********************************************************************}
  106. {* TCP network API *}
  107. {***********************************************************************}
  108. type
  109. _TCPSocket = record
  110. end;
  111. TTCPSocket = ^_TCPSocket;
  112. {* Open a TCP network socket
  113. If ip.host is INADDR_NONE or INADDR_ANY, this creates a local server
  114. socket on the given port, otherwise a TCP connection to the remote
  115. host and port is attempted. The address passed in should already be
  116. swapped to network byte order (addresses returned from
  117. SDLNet_ResolveHost() are already in the correct form).
  118. The newly created socket is returned, or NULL if there was an error.
  119. *}
  120. function SDLNet_TCP_Open(ip: PIPaddress): TTCPSocket cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_TCP_Open' {$ENDIF} {$ENDIF};
  121. {* Accept an incoming connection on the given server socket.
  122. The newly created socket is returned, or NULL if there was an error.
  123. *}
  124. function SDLNet_TCP_Accept(server: TTCPSocket): TTCPSocket cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_TCP_Accept' {$ENDIF} {$ENDIF};
  125. {* Get the IP address of the remote system associated with the socket.
  126. If the socket is a server socket, this function returns NULL.
  127. *}
  128. function SDLNet_TCP_GetPeerAddress(sock: TTCPSocket): PIPaddress cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_TCP_GetPeerAddress' {$ENDIF} {$ENDIF};
  129. {* Send 'len' bytes of 'data' over the non-server socket 'sock'
  130. This function returns the actual amount of data sent. If the return value
  131. is less than the amount of data sent, then either the remote connection was
  132. closed, or an unknown socket error occurred.
  133. *}
  134. function SDLNet_TCP_Send(sock: TTCPSocket; const data: Pointer; len: cint): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_TCP_Send' {$ENDIF} {$ENDIF};
  135. {* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
  136. and store them in the buffer pointed to by 'data'.
  137. This function returns the actual amount of data received. If the return
  138. value is less than or equal to zero, then either the remote connection was
  139. closed, or an unknown socket error occurred.
  140. *}
  141. function SDLNet_TCP_Recv(sock: TTCPSocket; data: Pointer; maxlen: cint): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_TCP_Recv' {$ENDIF} {$ENDIF};
  142. {* Close a TCP network socket *}
  143. procedure SDLNet_TCP_Close(sock: TTCPSocket) cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_TCP_Close' {$ENDIF} {$ENDIF};
  144. {***********************************************************************}
  145. {* UDP network API *}
  146. {***********************************************************************}
  147. const
  148. {* The maximum channels on a a UDP socket *}
  149. SDLNET_MAX_UDPCHANNELS = 32;
  150. {* The maximum addresses bound to a single UDP socket channel *}
  151. SDLNET_MAX_UDPADDRESSES = 4;
  152. type
  153. PPUDPSocket = ^PUDPSocket;
  154. PUDPSocket = ^TUDPSocket;
  155. TUDPSocket = record
  156. end;
  157. PPUDPPacket = ^PUDPPacket;
  158. PUDPPacket = ^TUDPPacket;
  159. TUDPPacket = record
  160. channel: cint; {* The src/dst channel of the packet *}
  161. data: pcuint8; {* The packet data *}
  162. len: cint; {* The length of the packet data *}
  163. maxlen: cint; {* The size of the data buffer *}
  164. status: cint; {* packet status after sending *}
  165. address: TIPaddress; {* The source/dest address of an incoming/outgoing packet *}
  166. end;
  167. {* Allocate/resize/free a single UDP packet 'size' bytes long.
  168. The new packet is returned, or NULL if the function ran out of memory.
  169. *}
  170. function SDLNet_AllocPacket(size: cint): PUDPPacket cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_AllocPacket' {$ENDIF} {$ENDIF};
  171. function SDLNet_ResizePacket(packet: PUDPPacket; newsize: cint): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_ResizePacket' {$ENDIF} {$ENDIF};
  172. procedure SDLNet_FreePacket(packet: PUDPPacket) cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_FreePacket' {$ENDIF} {$ENDIF};
  173. {* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets,
  174. each 'size' bytes long.
  175. A pointer to the first packet in the array is returned, or NULL if the
  176. function ran out of memory.
  177. *}
  178. function SDLNet_AllocPacketV(howmany: cint; size: cint): PPUDPPacket cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_AllocPacketV' {$ENDIF} {$ENDIF};
  179. procedure SDLNet_FreePacketV(packetV: PPUDPPacket) cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_FreePacketV' {$ENDIF} {$ENDIF};
  180. {* Open a UDP network socket
  181. If 'port' is non-zero, the UDP socket is bound to a local port.
  182. The 'port' should be given in native byte order, but is used
  183. internally in network (big endian) byte order, in addresses, etc.
  184. This allows other systems to send to this socket via a known port.
  185. *}
  186. function SDLNet_UDP_Open(port: cuint16): TUDPSocket cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_UDP_Open' {$ENDIF} {$ENDIF};
  187. {* Set the percentage of simulated packet loss for packets sent on the socket. *}
  188. procedure SDLNet_UDP_SetPacketLoss(sock: TUDPSocket; percent: cint) cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_UDP_SetPacketLoss' {$ENDIF} {$ENDIF};
  189. {* Bind the address 'address' to the requested channel on the UDP socket.
  190. If the channel is -1, then the first unbound channel that has not yet
  191. been bound to the maximum number of addresses will be bound with
  192. the given address as it's primary address.
  193. If the channel is already bound, this new address will be added to the
  194. list of valid source addresses for packets arriving on the channel.
  195. If the channel is not already bound, then the address becomes the primary
  196. address, to which all outbound packets on the channel are sent.
  197. This function returns the channel which was bound, or -1 on error.
  198. *}
  199. function SDLNet_UDP_Bind(sock: TUDPSocket; channel: cint; const address: PIPaddress): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_UDP_Bind' {$ENDIF} {$ENDIF};
  200. {* Unbind all addresses from the given channel *}
  201. procedure SDLNet_UDP_Unbind(sock: TUDPSocket; channel: cint) cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_UDP_Unbind' {$ENDIF} {$ENDIF};
  202. {* Get the primary IP address of the remote system associated with the
  203. socket and channel. If the channel is -1, then the primary IP port
  204. of the UDP socket is returned -- this is only meaningful for sockets
  205. opened with a specific port.
  206. If the channel is not bound and not -1, this function returns NULL.
  207. *}
  208. function SDLNet_UDP_GetPeerAddress(sock: TUDPSocket; channel: cint): PIPaddress cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_UDP_GetPeerAddress' {$ENDIF} {$ENDIF};
  209. {* Send a vector of packets to the the channels specified within the packet.
  210. If the channel specified in the packet is -1, the packet will be sent to
  211. the address in the 'src' member of the packet.
  212. Each packet will be updated with the status of the packet after it has
  213. been sent, -1 if the packet send failed.
  214. This function returns the number of packets sent.
  215. *}
  216. function SDLNet_UDP_SendV(sock: TUDPSocket; packets: PPUDPPacket; npackets: cint): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_UDP_SendV' {$ENDIF} {$ENDIF};
  217. {* Send a single packet to the specified channel.
  218. If the channel specified in the packet is -1, the packet will be sent to
  219. the address in the 'src' member of the packet.
  220. The packet will be updated with the status of the packet after it has
  221. been sent.
  222. This function returns 1 if the packet was sent, or 0 on error.
  223. NOTE:
  224. The maximum size of the packet is limited by the MTU (Maximum Transfer Unit)
  225. of the transport medium. It can be as low as 250 bytes for some PPP links,
  226. and as high as 1500 bytes for ethernet.
  227. *}
  228. function SDLNet_UDP_Send(sock: TUDPSocket; channel: cint; packet: PUDPPacket): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_UDP_Send' {$ENDIF} {$ENDIF};
  229. {* Receive a vector of pending packets from the UDP socket.
  230. The returned packets contain the source address and the channel they arrived
  231. on. If they did not arrive on a bound channel, the the channel will be set
  232. to -1.
  233. The channels are checked in highest to lowest order, so if an address is
  234. bound to multiple channels, the highest channel with the source address
  235. bound will be returned.
  236. This function returns the number of packets read from the network, or -1
  237. on error. This function does not block, so can return 0 packets pending.
  238. *}
  239. function SDLNet_UDP_RecvV(sock: TUDPSocket; packets: PPUDPPacket): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_UDP_RecvV' {$ENDIF} {$ENDIF};
  240. {* Receive a single packet from the UDP socket.
  241. The returned packet contains the source address and the channel it arrived
  242. on. If it did not arrive on a bound channel, the the channel will be set
  243. to -1.
  244. The channels are checked in highest to lowest order, so if an address is
  245. bound to multiple channels, the highest channel with the source address
  246. bound will be returned.
  247. This function returns the number of packets read from the network, or -1
  248. on error. This function does not block, so can return 0 packets pending.
  249. *}
  250. function SDLNet_UDP_Recv(sock: TUDPSocket; packet: PUDPPacket): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_UDP_Recv' {$ENDIF} {$ENDIF};
  251. {* Close a UDP network socket *}
  252. procedure SDLNet_UDP_Close(sock: TUDPSocket) cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_UDP_Close' {$ENDIF} {$ENDIF};
  253. {***********************************************************************}
  254. {* Hooks for checking sockets for available data *}
  255. {***********************************************************************}
  256. type
  257. PPSDLNet_SocketSet = ^PSDLNet_SocketSet;
  258. PSDLNet_SocketSet = ^TSDLNet_SocketSet;
  259. TSDLNet_SocketSet = record
  260. end;
  261. {* Any network socket can be safely cast to this socket type *}
  262. PPSDLNet_GenericSocket = ^PSDLNet_GenericSocket;
  263. PSDLNet_GenericSocket = ^TSDLNet_GenericSocket;
  264. TSDLNet_GenericSocket = record
  265. ready: cint;
  266. end;
  267. {* Allocate a socket set for use with SDLNet_CheckSockets()
  268. This returns a socket set for up to 'maxsockets' sockets, or NULL if
  269. the function ran out of memory.
  270. *}
  271. function SDLNet_AllocSocketSet(maxsockets: cint): TSDLNet_GenericSocket cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_AllocSocketSet' {$ENDIF} {$ENDIF};
  272. {* Add a socket to a set of sockets to be checked for available data *}
  273. function SDLNet_AddSocket(set_: TSDLNet_SocketSet; sock: TSDLNet_GenericSocket): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_AddSocket' {$ENDIF} {$ENDIF};
  274. //function SDLNet_TCP_AddSocket(set_: TSDLNet_SocketSet; sock: TTCPSocket): cint; inline;
  275. //function SDLNet_UDP_AddSocket(set_: TSDLNet_SocketSet; sock: TUDPSocket): cint; inline;
  276. {* Remove a socket from a set of sockets to be checked for available data *}
  277. function SDLNet_DelSocket(set_: TSDLNet_SocketSet; sock: TSDLNet_GenericSocket): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_DelSocket' {$ENDIF} {$ENDIF};
  278. //function SDLNet_TCP_DelSocket(set_: TSDLNet_SocketSet; sock: TTCPSocket): cint; inline;
  279. //function SDLNet_UDP_DelSocket(set_: TSDLNet_SocketSet; sock: TUDPSocket): cint; inline;
  280. {* This function checks to see if data is available for reading on the
  281. given set of sockets. If 'timeout' is 0, it performs a quick poll,
  282. otherwise the function returns when either data is available for
  283. reading, or the timeout in milliseconds has elapsed, which ever occurs
  284. first. This function returns the number of sockets ready for reading,
  285. or -1 if there was an error with the select() system call.
  286. *}
  287. function SDLNet_CheckSockets(set_: TSDLNet_SocketSet; timeout: cuint32): cint cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_CheckSockets' {$ENDIF} {$ENDIF};
  288. {* After calling SDLNet_CheckSockets(), you can use this function on a
  289. socket that was in the socket set, to find out if data is available
  290. for reading.
  291. *}
  292. function SDLNet_SocketReady(sock: TSDLNet_GenericSocket): cint; {$IFNDEF DELPHI} inline; {$ELSE} {$IFDEF DELPHI10UP} inline; {$ENDIF} {$ENDIF}
  293. {* Free a set of sockets allocated by SDL_NetAllocSocketSet() *}
  294. procedure SDLNet_FreeSocketSet(set_: TSDLNet_SocketSet) cdecl; external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_FreeSocketSet' {$ENDIF} {$ENDIF};
  295. {***********************************************************************}
  296. {* Error reporting functions *}
  297. {***********************************************************************}
  298. procedure SDLNet_SetError(const fmt: PAnsiChar; args: array of const); cdecl;
  299. external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_SetError' {$ENDIF} {$ENDIF};
  300. function SDLNet_GetError(): PAnsiChar; cdecl;
  301. external SDLNet_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDLNet_GetError' {$ENDIF} {$ENDIF};
  302. {***********************************************************************}
  303. {* Inline functions to read/write network data *}
  304. {***********************************************************************}
  305. {* Write a 16/32-bit value to network packet buffer *}
  306. //procedure SDLNet_Write16(value: cuint16; areap: Pointer); inline;
  307. //procedure SDLNet_Write32(value: cuint32; areap: Pointer); inline;
  308. {* Read a 16/32-bit value from network packet buffer *}
  309. //function SDLNet_Read16(const areap: Pointer): cuint16; inline;
  310. //function SDLNet_Read32(const areap: Pointer): cuint32; inline;
  311. implementation
  312. procedure SDL_NET_VERSION(Out X: TSDL_Version);
  313. begin
  314. X.major := SDL_NET_MAJOR_VERSION;
  315. X.minor := SDL_NET_MINOR_VERSION;
  316. X.patch := SDL_NET_PATCHLEVEL;
  317. end;
  318. (*
  319. function SDLNet_TCP_AddSocket(set_: TSDLNet_SocketSet; sock: TTCPSocket): cint;
  320. begin
  321. Result := SDLNet_AddSocket(set_, TSDLNet_GenericSocket(sock));
  322. end;
  323. function SDLNet_UDP_AddSocket(set_: TSDLNet_SocketSet; sock: TUDPSocket): cint;
  324. begin
  325. Result := SDLNet_AddSocket(set_, TSDLNet_GenericSocket(sock));
  326. end;
  327. function SDLNet_TCP_DelSocket(set_: TSDLNet_SocketSet; sock: TTCPSocket): cint;
  328. begin
  329. Result := SDLNet_DelSocket(set_, TSDLNet_GenericSocket(sock));
  330. end;
  331. function SDLNet_UDP_DelSocket(set_: TSDLNet_SocketSet; sock: TUDPSocket): cint;
  332. begin
  333. Result := SDLNet_DelSocket(set_, TSDLNet_GenericSocket(sock));
  334. end;
  335. *)
  336. function SDLNet_SocketReady(sock: TSDLNet_GenericSocket): cint;
  337. begin
  338. Result := sock.ready;
  339. end;
  340. (*
  341. procedure SDLNet_Write16(value: cuint16; areap: Pointer);
  342. begin
  343. pcuint16(areap) := SDL_SwapBE16(value);
  344. end;
  345. procedure SDLNet_Write32(value: cuint32; areap: Pointer);
  346. begin
  347. pcuint32(areap) := SDL_SwapBE32(value);
  348. end;
  349. {* Read a 16/32-bit value from network packet buffer *}
  350. function SDLNet_Read16(const areap: Pointer): cuint16;
  351. begin
  352. Result := SDL_SwapBE16(pcuint16(areap));
  353. end;
  354. function SDLNet_Read32(const areap: Pointer): cuint32;
  355. begin
  356. Result := SDL_SwapBE32(pcuint32(areap));
  357. end;
  358. *)
  359. end.