2024-11-05 00:57:12 +08:00
|
|
|
#ifndef NET_H
|
|
|
|
#define NET_H
|
|
|
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ifaddrs.h>
|
|
|
|
|
2024-11-17 21:15:44 +08:00
|
|
|
#define CLIENT_MAX_TIME 4
|
|
|
|
|
2024-11-05 00:57:12 +08:00
|
|
|
int net_init(unsigned int port);
|
2024-11-17 21:15:44 +08:00
|
|
|
void net_destroy();
|
2024-11-05 00:57:12 +08:00
|
|
|
int net_broadcast();
|
2024-11-17 21:15:44 +08:00
|
|
|
int net_listen_peers();
|
|
|
|
int net_prune_peers();
|
|
|
|
int net_send(void* buffer, size_t size);
|
2024-11-05 00:57:12 +08:00
|
|
|
int net_receive();
|
2024-11-17 21:15:44 +08:00
|
|
|
void net_print_peers();
|
|
|
|
int net_get_peers(struct sockaddr_in** peer_addr);
|
2024-11-05 00:57:12 +08:00
|
|
|
|
|
|
|
#endif
|