| 1 |
#ifndef FLATLINE_NET_H |
| 2 |
#define FLATLINE_NET_H |
| 3 |
|
| 4 |
#define pad1_size (sizeof(int64_t) - sizeof(short)) |
| 5 |
#define pad2_size (128 - (sizeof(short) + pad1_size + sizeof(int64_t))) |
| 6 |
|
| 7 |
|
| 8 |
typedef struct hostent hostent ; |
| 9 |
typedef struct in_addr in_addr; |
| 10 |
|
| 11 |
typedef struct { |
| 12 |
short ss_family; |
| 13 |
char pad1[pad1_size]; |
| 14 |
uint64_t pad64; |
| 15 |
char pad2[pad2_size]; |
| 16 |
} sockaddr_storage; |
| 17 |
|
| 18 |
typedef struct sockaddr sockaddr; |
| 19 |
typedef struct sockaddr_in sockaddr_in; |
| 20 |
typedef sockaddr_storage sockaddr_in6; |
| 21 |
|
| 22 |
void NetCatchError(); |
| 23 |
|
| 24 |
bool NetUDPServer_Listen(uint16_t port, bool (*packet_callback)(char* data, int datalen, int from)); |
| 25 |
bool NetUDPServer_Send(sockaddr* address, char* data, int datalen); |
| 26 |
|
| 27 |
int NetUDPSocket_Create(uint16_t port, sockaddr_in* address); |
| 28 |
int NetTCPSocket_Create(uint16_t port, sockaddr_in* address); |
| 29 |
int NetUDPSocket_Send(int socket, const sockaddr* address, const char* data, int datalen); |
| 30 |
void NetUDPSocket_Close(int sock); |
| 31 |
bool NetUDPSocket_Recieve(int socket, sockaddr_storage* address, char* data, uint16_t* datalen); |
| 32 |
|
| 33 |
#endif |