In order to support both IPv4 and IPv6 store a type struct sockaddr. Also remove specifying af_family as an arg. It will be determined using a getaddrinfo() func.
This commit is contained in:
parent
d5f6739fcd
commit
58645aae4b
@ -5,12 +5,12 @@
|
||||
|
||||
typedef struct net_t {
|
||||
int fd;
|
||||
struct sockaddr_in laddr, raddr, inaddr;
|
||||
struct sockaddr 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);
|
||||
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);
|
||||
void net_destroy(net_t *n);
|
||||
|
||||
ssize_t net_send(net_t *const n, const char *const buf, int buf_len);
|
||||
|
Loading…
Reference in New Issue
Block a user