Use net_close() to close sockets
So that it also works on Windows.
This commit is contained in:
parent
0792998cc2
commit
296047d82a
1 changed files with 3 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue