2024-03-22 03:50:58 +04:00
|
|
|
#ifndef _NET_H_
|
|
|
|
#define _NET_H_
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
typedef struct net_t {
|
|
|
|
int fd;
|
2024-03-24 19:38:00 +04:00
|
|
|
struct sockaddr laddr, raddr, inaddr;
|
2024-03-22 03:50:58 +04:00
|
|
|
socklen_t raddr_len, inaddr_len;
|
|
|
|
} net_t;
|
|
|
|
|
2024-03-24 19:38:00 +04:00
|
|
|
int net_client_init(net_t *const n, const char *const raddr, const char *const rport);
|
|
|
|
int net_server_init(net_t *const n, const char *const laddr, const char *const lport);
|
2024-03-22 03:50:58 +04:00
|
|
|
void net_destroy(net_t *n);
|
|
|
|
|
2024-03-24 17:55:39 +04:00
|
|
|
ssize_t net_send(net_t *const n, const char *const buf, int buf_len);
|
|
|
|
ssize_t net_recv(net_t *const n, void *const buf, size_t buf_len);
|
2024-03-22 03:50:58 +04:00
|
|
|
|
2024-03-25 00:56:42 +04:00
|
|
|
#endif /* _NET_H_ */
|