Use net_close() to close sockets

So that it also works on Windows.
This commit is contained in:
Romain Vimont 2019-05-31 23:32:53 +02:00
parent 0792998cc2
commit 296047d82a

View file

@ -33,7 +33,7 @@ net_connect(uint32_t addr, uint16_t port) {
if (connect(sock, (SOCKADDR *) &sin, sizeof(sin)) == SOCKET_ERROR) {
perror("connect");
close(sock);
net_close(sock);
return INVALID_SOCKET;
}
@ -61,13 +61,13 @@ net_listen(uint32_t addr, uint16_t port, int backlog) {
if (bind(sock, (SOCKADDR *) &sin, sizeof(sin)) == SOCKET_ERROR) {
perror("bind");
close(sock);
net_close(sock);
return INVALID_SOCKET;
}
if (listen(sock, backlog) == SOCKET_ERROR) {
perror("listen");
close(sock);
net_close(sock);
return INVALID_SOCKET;
}