enet.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. /**
  2. @file enet.h
  3. @brief ENet public header file
  4. */
  5. #ifndef __ENET_ENET_H__
  6. #define __ENET_ENET_H__
  7. #ifdef __cplusplus
  8. extern "C"
  9. {
  10. #endif
  11. #include <stdlib.h>
  12. #ifdef WIN32
  13. #include "enet/win32.h"
  14. #else
  15. #include "enet/unix.h"
  16. #endif
  17. #include "enet/types.h"
  18. #include "enet/protocol.h"
  19. #include "enet/list.h"
  20. #include "enet/callbacks.h"
  21. #define ENET_VERSION_MAJOR 1
  22. #define ENET_VERSION_MINOR 3
  23. #define ENET_VERSION_PATCH 2
  24. #define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch))
  25. #define ENET_VERSION ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR, ENET_VERSION_PATCH)
  26. typedef enet_uint32 ENetVersion;
  27. typedef enum _ENetSocketType
  28. {
  29. ENET_SOCKET_TYPE_STREAM = 1,
  30. ENET_SOCKET_TYPE_DATAGRAM = 2
  31. } ENetSocketType;
  32. typedef enum _ENetSocketWait
  33. {
  34. ENET_SOCKET_WAIT_NONE = 0,
  35. ENET_SOCKET_WAIT_SEND = (1 << 0),
  36. ENET_SOCKET_WAIT_RECEIVE = (1 << 1)
  37. } ENetSocketWait;
  38. typedef enum _ENetSocketOption
  39. {
  40. ENET_SOCKOPT_NONBLOCK = 1,
  41. ENET_SOCKOPT_BROADCAST = 2,
  42. ENET_SOCKOPT_RCVBUF = 3,
  43. ENET_SOCKOPT_SNDBUF = 4,
  44. ENET_SOCKOPT_REUSEADDR = 5
  45. } ENetSocketOption;
  46. enum
  47. {
  48. ENET_HOST_ANY = 0, /**< specifies the default server host */
  49. ENET_HOST_BROADCAST = 0xFFFFFFFF, /**< specifies a subnet-wide broadcast */
  50. ENET_PORT_ANY = 0 /**< specifies that a port should be automatically chosen */
  51. };
  52. /**
  53. * Portable internet address structure.
  54. *
  55. * The host must be specified in network byte-order, and the port must be in host
  56. * byte-order. The constant ENET_HOST_ANY may be used to specify the default
  57. * server host. The constant ENET_HOST_BROADCAST may be used to specify the
  58. * broadcast address (255.255.255.255). This makes sense for enet_host_connect,
  59. * but not for enet_host_create. Once a server responds to a broadcast, the
  60. * address is updated from ENET_HOST_BROADCAST to the server's actual IP address.
  61. */
  62. typedef struct _ENetAddress
  63. {
  64. enet_uint32 host;
  65. enet_uint16 port;
  66. } ENetAddress;
  67. /**
  68. * Packet flag bit constants.
  69. *
  70. * The host must be specified in network byte-order, and the port must be in
  71. * host byte-order. The constant ENET_HOST_ANY may be used to specify the
  72. * default server host.
  73. @sa ENetPacket
  74. */
  75. typedef enum _ENetPacketFlag
  76. {
  77. /** packet must be received by the target peer and resend attempts should be
  78. * made until the packet is delivered */
  79. ENET_PACKET_FLAG_RELIABLE = (1 << 0),
  80. /** packet will not be sequenced with other packets
  81. * not supported for reliable packets
  82. */
  83. ENET_PACKET_FLAG_UNSEQUENCED = (1 << 1),
  84. /** packet will not allocate data, and user must supply it instead */
  85. ENET_PACKET_FLAG_NO_ALLOCATE = (1 << 2),
  86. /** packet will be fragmented using unreliable (instead of reliable) sends
  87. * if it exceeds the MTU */
  88. ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT = (1 << 3)
  89. } ENetPacketFlag;
  90. struct _ENetPacket;
  91. typedef void (ENET_CALLBACK * ENetPacketFreeCallback) (struct _ENetPacket *);
  92. /**
  93. * ENet packet structure.
  94. *
  95. * An ENet data packet that may be sent to or received from a peer. The shown
  96. * fields should only be read and never modified. The data field contains the
  97. * allocated data for the packet. The dataLength fields specifies the length
  98. * of the allocated data. The flags field is either 0 (specifying no flags),
  99. * or a bitwise-or of any combination of the following flags:
  100. *
  101. * ENET_PACKET_FLAG_RELIABLE - packet must be received by the target peer
  102. * and resend attempts should be made until the packet is delivered
  103. *
  104. * ENET_PACKET_FLAG_UNSEQUENCED - packet will not be sequenced with other packets
  105. * (not supported for reliable packets)
  106. *
  107. * ENET_PACKET_FLAG_NO_ALLOCATE - packet will not allocate data, and user must supply it instead
  108. @sa ENetPacketFlag
  109. */
  110. typedef struct _ENetPacket
  111. {
  112. size_t referenceCount; /**< internal use only */
  113. enet_uint32 flags; /**< bitwise-or of ENetPacketFlag constants */
  114. enet_uint8 * data; /**< allocated data for packet */
  115. size_t dataLength; /**< length of data */
  116. ENetPacketFreeCallback freeCallback; /**< function to be called when the packet is no longer in use */
  117. } ENetPacket;
  118. typedef struct _ENetAcknowledgement
  119. {
  120. ENetListNode acknowledgementList;
  121. enet_uint32 sentTime;
  122. ENetProtocol command;
  123. } ENetAcknowledgement;
  124. typedef struct _ENetOutgoingCommand
  125. {
  126. ENetListNode outgoingCommandList;
  127. enet_uint16 reliableSequenceNumber;
  128. enet_uint16 unreliableSequenceNumber;
  129. enet_uint32 sentTime;
  130. enet_uint32 roundTripTimeout;
  131. enet_uint32 roundTripTimeoutLimit;
  132. enet_uint32 fragmentOffset;
  133. enet_uint16 fragmentLength;
  134. enet_uint16 sendAttempts;
  135. ENetProtocol command;
  136. ENetPacket * packet;
  137. } ENetOutgoingCommand;
  138. typedef struct _ENetIncomingCommand
  139. {
  140. ENetListNode incomingCommandList;
  141. enet_uint16 reliableSequenceNumber;
  142. enet_uint16 unreliableSequenceNumber;
  143. ENetProtocol command;
  144. enet_uint32 fragmentCount;
  145. enet_uint32 fragmentsRemaining;
  146. enet_uint32 * fragments;
  147. ENetPacket * packet;
  148. } ENetIncomingCommand;
  149. typedef enum _ENetPeerState
  150. {
  151. ENET_PEER_STATE_DISCONNECTED = 0,
  152. ENET_PEER_STATE_CONNECTING = 1,
  153. ENET_PEER_STATE_ACKNOWLEDGING_CONNECT = 2,
  154. ENET_PEER_STATE_CONNECTION_PENDING = 3,
  155. ENET_PEER_STATE_CONNECTION_SUCCEEDED = 4,
  156. ENET_PEER_STATE_CONNECTED = 5,
  157. ENET_PEER_STATE_DISCONNECT_LATER = 6,
  158. ENET_PEER_STATE_DISCONNECTING = 7,
  159. ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT = 8,
  160. ENET_PEER_STATE_ZOMBIE = 9
  161. } ENetPeerState;
  162. #ifndef ENET_BUFFER_MAXIMUM
  163. #define ENET_BUFFER_MAXIMUM (1 + 2 * ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS)
  164. #endif
  165. enum
  166. {
  167. ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024,
  168. ENET_HOST_SEND_BUFFER_SIZE = 256 * 1024,
  169. ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL = 1000,
  170. ENET_HOST_DEFAULT_MTU = 1400,
  171. ENET_PEER_DEFAULT_ROUND_TRIP_TIME = 500,
  172. ENET_PEER_DEFAULT_PACKET_THROTTLE = 32,
  173. ENET_PEER_PACKET_THROTTLE_SCALE = 32,
  174. ENET_PEER_PACKET_THROTTLE_COUNTER = 7,
  175. ENET_PEER_PACKET_THROTTLE_ACCELERATION = 2,
  176. ENET_PEER_PACKET_THROTTLE_DECELERATION = 2,
  177. ENET_PEER_PACKET_THROTTLE_INTERVAL = 5000,
  178. ENET_PEER_PACKET_LOSS_SCALE = (1 << 16),
  179. ENET_PEER_PACKET_LOSS_INTERVAL = 10000,
  180. ENET_PEER_WINDOW_SIZE_SCALE = 64 * 1024,
  181. ENET_PEER_TIMEOUT_LIMIT = 32,
  182. ENET_PEER_TIMEOUT_MINIMUM = 5000,
  183. ENET_PEER_TIMEOUT_MAXIMUM = 30000,
  184. ENET_PEER_PING_INTERVAL = 500,
  185. ENET_PEER_UNSEQUENCED_WINDOWS = 64,
  186. ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 1024,
  187. ENET_PEER_FREE_UNSEQUENCED_WINDOWS = 32,
  188. ENET_PEER_RELIABLE_WINDOWS = 16,
  189. ENET_PEER_RELIABLE_WINDOW_SIZE = 0x1000,
  190. ENET_PEER_FREE_RELIABLE_WINDOWS = 8
  191. };
  192. typedef struct _ENetChannel
  193. {
  194. enet_uint16 outgoingReliableSequenceNumber;
  195. enet_uint16 outgoingUnreliableSequenceNumber;
  196. enet_uint16 usedReliableWindows;
  197. enet_uint16 reliableWindows [ENET_PEER_RELIABLE_WINDOWS];
  198. enet_uint16 incomingReliableSequenceNumber;
  199. enet_uint16 incomingUnreliableSequenceNumber;
  200. ENetList incomingReliableCommands;
  201. ENetList incomingUnreliableCommands;
  202. } ENetChannel;
  203. /**
  204. * An ENet peer which data packets may be sent or received from.
  205. *
  206. * No fields should be modified unless otherwise specified.
  207. */
  208. typedef struct _ENetPeer
  209. {
  210. ENetListNode dispatchList;
  211. struct _ENetHost * host;
  212. enet_uint16 outgoingPeerID;
  213. enet_uint16 incomingPeerID;
  214. enet_uint32 connectID;
  215. enet_uint8 outgoingSessionID;
  216. enet_uint8 incomingSessionID;
  217. ENetAddress address; /**< Internet address of the peer */
  218. void * data; /**< Application private data, may be freely modified */
  219. ENetPeerState state;
  220. ENetChannel * channels;
  221. size_t channelCount; /**< Number of channels allocated for communication with peer */
  222. enet_uint32 incomingBandwidth; /**< Downstream bandwidth of the client in bytes/second */
  223. enet_uint32 outgoingBandwidth; /**< Upstream bandwidth of the client in bytes/second */
  224. enet_uint32 incomingBandwidthThrottleEpoch;
  225. enet_uint32 outgoingBandwidthThrottleEpoch;
  226. enet_uint32 incomingDataTotal;
  227. enet_uint32 outgoingDataTotal;
  228. enet_uint32 lastSendTime;
  229. enet_uint32 lastReceiveTime;
  230. enet_uint32 nextTimeout;
  231. enet_uint32 earliestTimeout;
  232. enet_uint32 packetLossEpoch;
  233. enet_uint32 packetsSent;
  234. enet_uint32 packetsLost;
  235. enet_uint32 packetLoss; /**< mean packet loss of reliable packets as a ratio with respect to the constant ENET_PEER_PACKET_LOSS_SCALE */
  236. enet_uint32 packetLossVariance;
  237. enet_uint32 packetThrottle;
  238. enet_uint32 packetThrottleLimit;
  239. enet_uint32 packetThrottleCounter;
  240. enet_uint32 packetThrottleEpoch;
  241. enet_uint32 packetThrottleAcceleration;
  242. enet_uint32 packetThrottleDeceleration;
  243. enet_uint32 packetThrottleInterval;
  244. enet_uint32 lastRoundTripTime;
  245. enet_uint32 lowestRoundTripTime;
  246. enet_uint32 lastRoundTripTimeVariance;
  247. enet_uint32 highestRoundTripTimeVariance;
  248. enet_uint32 roundTripTime; /**< mean round trip time (RTT), in milliseconds, between sending a reliable packet and receiving its acknowledgement */
  249. enet_uint32 roundTripTimeVariance;
  250. enet_uint32 mtu;
  251. enet_uint32 windowSize;
  252. enet_uint32 reliableDataInTransit;
  253. enet_uint16 outgoingReliableSequenceNumber;
  254. ENetList acknowledgements;
  255. ENetList sentReliableCommands;
  256. ENetList sentUnreliableCommands;
  257. ENetList outgoingReliableCommands;
  258. ENetList outgoingUnreliableCommands;
  259. ENetList dispatchedCommands;
  260. int needsDispatch;
  261. enet_uint16 incomingUnsequencedGroup;
  262. enet_uint16 outgoingUnsequencedGroup;
  263. enet_uint32 unsequencedWindow [ENET_PEER_UNSEQUENCED_WINDOW_SIZE / 32];
  264. enet_uint32 eventData;
  265. } ENetPeer;
  266. /** An ENet packet compressor for compressing UDP packets before socket sends or receives.
  267. */
  268. typedef struct _ENetCompressor
  269. {
  270. /** Context data for the compressor. Must be non-NULL. */
  271. void * context;
  272. /** Compresses from inBuffers[0:inBufferCount-1], containing inLimit bytes, to outData, outputting at most outLimit bytes. Should return 0 on failure. */
  273. size_t (ENET_CALLBACK * compress) (void * context, const ENetBuffer * inBuffers, size_t inBufferCount, size_t inLimit, enet_uint8 * outData, size_t outLimit);
  274. /** Decompresses from inData, containing inLimit bytes, to outData, outputting at most outLimit bytes. Should return 0 on failure. */
  275. size_t (ENET_CALLBACK * decompress) (void * context, const enet_uint8 * inData, size_t inLimit, enet_uint8 * outData, size_t outLimit);
  276. /** Destroys the context when compression is disabled or the host is destroyed. May be NULL. */
  277. void (ENET_CALLBACK * destroy) (void * context);
  278. } ENetCompressor;
  279. /** Callback that computes the checksum of the data held in buffers[0:bufferCount-1] */
  280. typedef enet_uint32 (ENET_CALLBACK * ENetChecksumCallback) (const ENetBuffer * buffers, size_t bufferCount);
  281. /** An ENet host for communicating with peers.
  282. *
  283. * No fields should be modified unless otherwise stated.
  284. @sa enet_host_create()
  285. @sa enet_host_destroy()
  286. @sa enet_host_connect()
  287. @sa enet_host_service()
  288. @sa enet_host_flush()
  289. @sa enet_host_broadcast()
  290. @sa enet_host_compress()
  291. @sa enet_host_compress_with_range_coder()
  292. @sa enet_host_channel_limit()
  293. @sa enet_host_bandwidth_limit()
  294. @sa enet_host_bandwidth_throttle()
  295. */
  296. typedef struct _ENetHost
  297. {
  298. ENetSocket socket;
  299. ENetAddress address; /**< Internet address of the host */
  300. enet_uint32 incomingBandwidth; /**< downstream bandwidth of the host */
  301. enet_uint32 outgoingBandwidth; /**< upstream bandwidth of the host */
  302. enet_uint32 bandwidthThrottleEpoch;
  303. enet_uint32 mtu;
  304. enet_uint32 randomSeed;
  305. int recalculateBandwidthLimits;
  306. ENetPeer * peers; /**< array of peers allocated for this host */
  307. size_t peerCount; /**< number of peers allocated for this host */
  308. size_t channelLimit; /**< maximum number of channels allowed for connected peers */
  309. enet_uint32 serviceTime;
  310. ENetList dispatchQueue;
  311. int continueSending;
  312. size_t packetSize;
  313. enet_uint16 headerFlags;
  314. ENetProtocol commands [ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS];
  315. size_t commandCount;
  316. ENetBuffer buffers [ENET_BUFFER_MAXIMUM];
  317. size_t bufferCount;
  318. ENetChecksumCallback checksum; /**< callback the user can set to enable packet checksums for this host */
  319. ENetCompressor compressor;
  320. enet_uint8 packetData [2][ENET_PROTOCOL_MAXIMUM_MTU];
  321. ENetAddress receivedAddress;
  322. enet_uint8 * receivedData;
  323. size_t receivedDataLength;
  324. enet_uint32 totalSentData; /**< total data sent, user should reset to 0 as needed to prevent overflow */
  325. enet_uint32 totalSentPackets; /**< total UDP packets sent, user should reset to 0 as needed to prevent overflow */
  326. enet_uint32 totalReceivedData; /**< total data received, user should reset to 0 as needed to prevent overflow */
  327. enet_uint32 totalReceivedPackets; /**< total UDP packets received, user should reset to 0 as needed to prevent overflow */
  328. } ENetHost;
  329. /**
  330. * An ENet event type, as specified in @ref ENetEvent.
  331. */
  332. typedef enum _ENetEventType
  333. {
  334. /** no event occurred within the specified time limit */
  335. ENET_EVENT_TYPE_NONE = 0,
  336. /** a connection request initiated by enet_host_connect has completed.
  337. * The peer field contains the peer which successfully connected.
  338. */
  339. ENET_EVENT_TYPE_CONNECT = 1,
  340. /** a peer has disconnected. This event is generated on a successful
  341. * completion of a disconnect initiated by enet_pper_disconnect, if
  342. * a peer has timed out, or if a connection request intialized by
  343. * enet_host_connect has timed out. The peer field contains the peer
  344. * which disconnected. The data field contains user supplied data
  345. * describing the disconnection, or 0, if none is available.
  346. */
  347. ENET_EVENT_TYPE_DISCONNECT = 2,
  348. /** a packet has been received from a peer. The peer field specifies the
  349. * peer which sent the packet. The channelID field specifies the channel
  350. * number upon which the packet was received. The packet field contains
  351. * the packet that was received; this packet must be destroyed with
  352. * enet_packet_destroy after use.
  353. */
  354. ENET_EVENT_TYPE_RECEIVE = 3
  355. } ENetEventType;
  356. /**
  357. * An ENet event as returned by enet_host_service().
  358. @sa enet_host_service
  359. */
  360. typedef struct _ENetEvent
  361. {
  362. ENetEventType type; /**< type of the event */
  363. ENetPeer * peer; /**< peer that generated a connect, disconnect or receive event */
  364. enet_uint8 channelID; /**< channel on the peer that generated the event, if appropriate */
  365. enet_uint32 data; /**< data associated with the event, if appropriate */
  366. ENetPacket * packet; /**< packet associated with the event, if appropriate */
  367. } ENetEvent;
  368. /** @defgroup global ENet global functions
  369. @{
  370. */
  371. /**
  372. Initializes ENet globally. Must be called prior to using any functions in
  373. ENet.
  374. @returns 0 on success, < 0 on failure
  375. */
  376. ENET_API int enet_initialize (void);
  377. /**
  378. Initializes ENet globally and supplies user-overridden callbacks. Must be called prior to using any functions in ENet. Do not use enet_initialize() if you use this variant. Make sure the ENetCallbacks structure is zeroed out so that any additional callbacks added in future versions will be properly ignored.
  379. @param version the constant ENET_VERSION should be supplied so ENet knows which version of ENetCallbacks struct to use
  380. @param inits user-overriden callbacks where any NULL callbacks will use ENet's defaults
  381. @returns 0 on success, < 0 on failure
  382. */
  383. ENET_API int enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits);
  384. /**
  385. Shuts down ENet globally. Should be called when a program that has
  386. initialized ENet exits.
  387. */
  388. ENET_API void enet_deinitialize (void);
  389. /** @} */
  390. /** @defgroup private ENet private implementation functions */
  391. /**
  392. Returns the wall-time in milliseconds. Its initial value is unspecified
  393. unless otherwise set.
  394. */
  395. ENET_API enet_uint32 enet_time_get (void);
  396. /**
  397. Sets the current wall-time in milliseconds.
  398. */
  399. ENET_API void enet_time_set (enet_uint32);
  400. /** @defgroup socket ENet socket functions
  401. @{
  402. */
  403. ENET_API ENetSocket enet_socket_create (ENetSocketType);
  404. ENET_API int enet_socket_bind (ENetSocket, const ENetAddress *);
  405. ENET_API int enet_socket_listen (ENetSocket, int);
  406. ENET_API ENetSocket enet_socket_accept (ENetSocket, ENetAddress *);
  407. ENET_API int enet_socket_connect (ENetSocket, const ENetAddress *);
  408. ENET_API int enet_socket_send (ENetSocket, const ENetAddress *, const ENetBuffer *, size_t);
  409. ENET_API int enet_socket_receive (ENetSocket, ENetAddress *, ENetBuffer *, size_t);
  410. ENET_API int enet_socket_wait (ENetSocket, enet_uint32 *, enet_uint32);
  411. ENET_API int enet_socket_set_option (ENetSocket, ENetSocketOption, int);
  412. ENET_API void enet_socket_destroy (ENetSocket);
  413. ENET_API int enet_socketset_select (ENetSocket, ENetSocketSet *, ENetSocketSet *, enet_uint32);
  414. /** @} */
  415. /** @defgroup Address ENet address functions
  416. @{
  417. */
  418. /** Attempts to resolve the host named by the parameter hostName and sets
  419. the host field in the address parameter if successful.
  420. @param address destination to store resolved address
  421. @param hostName host name to lookup
  422. @retval 0 on success
  423. @retval < 0 on failure
  424. @returns the address of the given hostName in address on success
  425. */
  426. ENET_API int enet_address_set_host (ENetAddress * address, const char * hostName);
  427. /** Gives the printable form of the ip address specified in the address parameter.
  428. @param address address printed
  429. @param hostName destination for name, must not be NULL
  430. @param nameLength maximum length of hostName.
  431. @returns the null-terminated name of the host in hostName on success
  432. @retval 0 on success
  433. @retval < 0 on failure
  434. */
  435. ENET_API int enet_address_get_host_ip (const ENetAddress * address, char * hostName, size_t nameLength);
  436. /** Attempts to do a reverse lookup of the host field in the address parameter.
  437. @param address address used for reverse lookup
  438. @param hostName destination for name, must not be NULL
  439. @param nameLength maximum length of hostName.
  440. @returns the null-terminated name of the host in hostName on success
  441. @retval 0 on success
  442. @retval < 0 on failure
  443. */
  444. ENET_API int enet_address_get_host (const ENetAddress * address, char * hostName, size_t nameLength);
  445. /** @} */
  446. ENET_API ENetPacket * enet_packet_create (const void *, size_t, enet_uint32);
  447. ENET_API void enet_packet_destroy (ENetPacket *);
  448. ENET_API int enet_packet_resize (ENetPacket *, size_t);
  449. extern enet_uint32 enet_crc32 (const ENetBuffer *, size_t);
  450. ENET_API ENetHost * enet_host_create (const ENetAddress *, size_t, size_t, enet_uint32, enet_uint32);
  451. ENET_API void enet_host_destroy (ENetHost *);
  452. ENET_API ENetPeer * enet_host_connect (ENetHost *, const ENetAddress *, size_t, enet_uint32);
  453. ENET_API int enet_host_check_events (ENetHost *, ENetEvent *);
  454. ENET_API int enet_host_service (ENetHost *, ENetEvent *, enet_uint32);
  455. ENET_API void enet_host_flush (ENetHost *);
  456. ENET_API void enet_host_broadcast (ENetHost *, enet_uint8, ENetPacket *);
  457. ENET_API void enet_host_compress (ENetHost *, const ENetCompressor *);
  458. ENET_API int enet_host_compress_with_range_coder (ENetHost * host);
  459. ENET_API void enet_host_channel_limit (ENetHost *, size_t);
  460. ENET_API void enet_host_bandwidth_limit (ENetHost *, enet_uint32, enet_uint32);
  461. extern void enet_host_bandwidth_throttle (ENetHost *);
  462. ENET_API int enet_peer_send (ENetPeer *, enet_uint8, ENetPacket *);
  463. ENET_API ENetPacket * enet_peer_receive (ENetPeer *, enet_uint8 * channelID);
  464. ENET_API void enet_peer_ping (ENetPeer *);
  465. ENET_API void enet_peer_reset (ENetPeer *);
  466. ENET_API void enet_peer_disconnect (ENetPeer *, enet_uint32);
  467. ENET_API void enet_peer_disconnect_now (ENetPeer *, enet_uint32);
  468. ENET_API void enet_peer_disconnect_later (ENetPeer *, enet_uint32);
  469. ENET_API void enet_peer_throttle_configure (ENetPeer *, enet_uint32, enet_uint32, enet_uint32);
  470. extern int enet_peer_throttle (ENetPeer *, enet_uint32);
  471. extern void enet_peer_reset_queues (ENetPeer *);
  472. extern void enet_peer_setup_outgoing_command (ENetPeer *, ENetOutgoingCommand *);
  473. extern ENetOutgoingCommand * enet_peer_queue_outgoing_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32, enet_uint16);
  474. extern ENetIncomingCommand * enet_peer_queue_incoming_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32);
  475. extern ENetAcknowledgement * enet_peer_queue_acknowledgement (ENetPeer *, const ENetProtocol *, enet_uint16);
  476. extern void enet_peer_dispatch_incoming_unreliable_commands (ENetPeer *, ENetChannel *);
  477. extern void enet_peer_dispatch_incoming_reliable_commands (ENetPeer *, ENetChannel *);
  478. ENET_API void * enet_range_coder_create (void);
  479. ENET_API void enet_range_coder_destroy (void *);
  480. ENET_API size_t enet_range_coder_compress (void *, const ENetBuffer *, size_t, size_t, enet_uint8 *, size_t);
  481. ENET_API size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t, enet_uint8 *, size_t);
  482. extern size_t enet_protocol_command_size (enet_uint8);
  483. #ifdef __cplusplus
  484. }
  485. #endif
  486. #endif /* __ENET_ENET_H__ */