2024-03-22 03:50:58 +04:00
|
|
|
#ifndef _NET_H_
|
|
|
|
#define _NET_H_
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
typedef struct net_t {
|
|
|
|
int fd;
|
|
|
|
struct sockaddr_in laddr, raddr, inaddr;
|
|
|
|
socklen_t raddr_len, inaddr_len;
|
|
|
|
} net_t;
|
|
|
|
|
|
|
|
int net_client_init(net_t *const n, const int af_family, const char *const raddr, const int rport);
|
|
|
|
int net_server_init(net_t *const n, const int af_family, const char *const laddr, const int lport);
|
|
|
|
void net_destroy(net_t *n);
|
|
|
|
|
2024-03-24 16:31:10 +04:00
|
|
|
int net_send(net_t *const n, const char *const buf, const int buf_len);
|
|
|
|
int net_recv(net_t *const n, void *buf, size_t buf_len);
|
2024-03-22 03:50:58 +04:00
|
|
|
|
|
|
|
#endif /* _NET_H_ */
|