In net.c sockaddr structures' had their *_len fields set to 0, so recvfrom didn't fill an inaddr field.
This commit is contained in:
parent
58c3b3fada
commit
b225b63cdf
@ -33,6 +33,7 @@ int net_client_init(net_t *const n, const char *const raddr, const char *const r
|
||||
|
||||
memset(&n->raddr, 0, sizeof(n->raddr));
|
||||
memcpy(&n->raddr, cri->ai_addr, sizeof(n->raddr));
|
||||
n->raddr_len = sizeof(n->raddr);
|
||||
|
||||
freeaddrinfo(ri);
|
||||
|
||||
@ -69,9 +70,10 @@ int net_server_init(net_t *const n, const char *const laddr, const char *const l
|
||||
}
|
||||
|
||||
memset(&n->inaddr, 0, sizeof(n->inaddr));
|
||||
n->inaddr_len = 0;
|
||||
n->inaddr_len = sizeof(n->inaddr);
|
||||
|
||||
memset(&n->raddr, 0, sizeof(n->raddr));
|
||||
n->raddr_len = sizeof(n->raddr);
|
||||
|
||||
memset(&n->laddr, 0, sizeof(n->laddr));
|
||||
memcpy(&n->laddr, cli->ai_addr, sizeof(n->raddr));
|
||||
@ -88,10 +90,10 @@ void net_destroy(net_t *n) {
|
||||
}
|
||||
|
||||
memset(&n->raddr, 0, sizeof(n->raddr));
|
||||
n->raddr_len = 0;
|
||||
n->raddr_len = sizeof(n->raddr);
|
||||
memset(&n->laddr, 0, sizeof(n->laddr));
|
||||
memset(&n->inaddr, 0, sizeof(n->inaddr));
|
||||
n->inaddr_len = 0;
|
||||
n->inaddr_len = sizeof(n->inaddr);
|
||||
}
|
||||
|
||||
ssize_t net_send(net_t *const n, const char *const buf, int buf_len) {
|
||||
|
Loading…
Reference in New Issue
Block a user