added opaque data types
added stubs and started tests
This commit is contained in:
parent
082a0c85ce
commit
9cc0f80909
1 changed files with 653 additions and 213 deletions
87
src/raylib.h
87
src/raylib.h
|
|
@ -109,6 +109,12 @@
|
|||
#define SOCKET_MAX_UDPCHANNELS (32)
|
||||
#define SOCKET_MAX_UDPADDRESSES (4)
|
||||
|
||||
//
|
||||
#define ADDRESS_IPV4_ADDRSTRLEN 22
|
||||
#define ADDRESS_IPV6_ADDRSTRLEN 65
|
||||
#define ADDRESS_TYPE_IPV4 2
|
||||
#define ADDRESS_TYPE_IPV6 23
|
||||
|
||||
// getnameinfo() defines
|
||||
#define NAME_INFO_DEFAULT 0x00 /* No flags set */
|
||||
#define NAME_INFO_NOFQDN 0x01 /* Only return nodename portion for local hosts */
|
||||
|
|
@ -577,15 +583,22 @@ typedef struct SocketResult
|
|||
Socket *socket;
|
||||
} SocketResult;
|
||||
|
||||
//
|
||||
typedef struct Packet
|
||||
{
|
||||
uint32_t size; // The total size of bytes in data
|
||||
uint32_t offs; // The offset to data access
|
||||
uint32_t maxs; // The max size of data
|
||||
uint8_t* data; // Data stored in network byte order
|
||||
//
|
||||
typedef struct Packet
|
||||
{
|
||||
uint32_t size; // The total size of bytes in data
|
||||
uint32_t offs; // The offset to data access
|
||||
uint32_t maxs; // The max size of data
|
||||
uint8_t* data; // Data stored in network byte order
|
||||
} Packet;
|
||||
|
||||
//
|
||||
typedef struct _AddressInformation * AddressInformation;
|
||||
typedef struct _SocketAddress * SocketAddress;
|
||||
typedef struct _SocketAddressIPv4 * SocketAddressIPv4;
|
||||
typedef struct _SocketAddressIPv6 * SocketAddressIPv6;
|
||||
typedef struct _SocketAddressStorage *SocketAddressStorage;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Enumerators Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
@ -1576,48 +1589,50 @@ extern "C"
|
|||
RLAPI bool InitNetwork(void);
|
||||
RLAPI void CloseNetwork(void);
|
||||
|
||||
// Protocol-independent name resolution from an address to an ANSI host name and from a port number to the ANSI service name.
|
||||
RLAPI char *ResolveIP(const char *host, const char *port, int flags);
|
||||
|
||||
// Protocol-independent translation from an ANSI host name to an address.
|
||||
RLAPI char *ResolveHost(const char *address, const char *port);
|
||||
// Address API
|
||||
RLAPI void ResolveIP(const char *host, const char *port, int flags, char* outhost);
|
||||
RLAPI int ResolveHost(const char *address, const char *port, struct _AddressInformation* addr);
|
||||
RLAPI int GetAddressFamily();
|
||||
RLAPI int GetAddressSocketType(AddressInformation address);
|
||||
RLAPI int GetAddressProtocol(AddressInformation address);
|
||||
RLAPI void PrintAddressInfo(AddressInformation address);
|
||||
RLAPI AddressInformation AllocAddress();
|
||||
RLAPI struct _AddressInformation **AllocAddressList(int size);
|
||||
|
||||
// Socket API
|
||||
RLAPI bool SocketCreate(SocketConfig *cfg, SocketResult *res);
|
||||
RLAPI void SocketClose(SocketChannel socket);
|
||||
RLAPI bool SocketListen(SocketConfig *cfg, SocketResult *res);
|
||||
RLAPI bool SocketConnect(SocketConfig *cfg, SocketResult *res);
|
||||
RLAPI void SocketClose(SocketChannel socket);
|
||||
RLAPI Socket *SocketAccept(Socket *server, SocketConfig *cfg);
|
||||
RLAPI int SocketSend(Socket *socket, const void *datap, int len);
|
||||
RLAPI int SocketReceive(Socket *socket, void *data, int maxlen, int timeout);
|
||||
RLAPI int SocketSend(Socket *socket, const void *datap, int len);
|
||||
RLAPI int SocketReceive(Socket *socket, void *data, int maxlen, int timeout);
|
||||
|
||||
// Socket set methods for async i/o
|
||||
RLAPI Socket *AllocSocket();
|
||||
RLAPI SocketResult *AllocSocketResult();
|
||||
RLAPI void FreeSocket(Socket **sock);
|
||||
RLAPI void FreeSocketResult(SocketResult **result);
|
||||
|
||||
// Socket I/O API
|
||||
RLAPI bool IsSocketReady(Socket* sock);
|
||||
RLAPI SocketSet* AllocSocketSet(int max);
|
||||
RLAPI void FreeSocketSet(SocketSet* sockset);
|
||||
RLAPI int AddSocket(SocketSet* set, Socket* sock);
|
||||
RLAPI int RemoveSocket(SocketSet* set, Socket* sock);
|
||||
RLAPI int CheckSockets(SocketSet* set, unsigned int timeout);
|
||||
|
||||
// Creation and allocation
|
||||
RLAPI SocketResult *AllocSocketResult();
|
||||
RLAPI void FreeSocketResult(SocketResult *result);
|
||||
RLAPI Socket *AllocSocket();
|
||||
RLAPI void FreeSocket(Socket *sock);
|
||||
|
||||
|
||||
// Data packets and helpers
|
||||
Packet* AllocPacket(int size);
|
||||
void FreePacket(Packet* packet);
|
||||
void PacketSend(Packet* packet);
|
||||
void PacketReceive(Packet* packet);
|
||||
void PacketWrite8(Packet* packet, uint16_t value);
|
||||
void PacketWrite16(Packet* packet, uint16_t value);
|
||||
void PacketWrite32(Packet* packet, uint32_t value);
|
||||
void PacketWrite64(Packet* packet, uint64_t value);
|
||||
uint16_t PacketRead8(Packet* packet);
|
||||
uint16_t PacketRead16(Packet* packet);
|
||||
uint32_t PacketRead32(Packet* packet);
|
||||
|
||||
// Packet API
|
||||
Packet * AllocPacket(int size);
|
||||
void FreePacket(Packet *packet);
|
||||
void PacketSend(Packet* packet);
|
||||
void PacketReceive(Packet* packet);
|
||||
void PacketWrite8(Packet* packet, uint16_t value);
|
||||
void PacketWrite16(Packet* packet, uint16_t value);
|
||||
void PacketWrite32(Packet* packet, uint32_t value);
|
||||
void PacketWrite64(Packet* packet, uint64_t value);
|
||||
uint16_t PacketRead8(Packet* packet);
|
||||
uint16_t PacketRead16(Packet* packet);
|
||||
uint32_t PacketRead32(Packet* packet);
|
||||
uint64_t PacketRead64(Packet* packet);
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue