mirror of https://github.com/mgba-emu/mgba.git
Util: Use closesocket on Windows
This commit is contained in:
parent
d3a637fbae
commit
b1691c9527
1
CHANGES
1
CHANGES
|
@ -18,6 +18,7 @@ Bugfixes:
|
||||||
- GBA Serialize: Fix memory corruption bug in GBAExtdataSerialize
|
- GBA Serialize: Fix memory corruption bug in GBAExtdataSerialize
|
||||||
- GBA Serialize: Fix loading savegames from savestates
|
- GBA Serialize: Fix loading savegames from savestates
|
||||||
- All: Fix several file handle leaks
|
- All: Fix several file handle leaks
|
||||||
|
- Util: Use closesocket on Windows
|
||||||
Misc:
|
Misc:
|
||||||
- GBA: Slightly optimize GBAProcessEvents
|
- GBA: Slightly optimize GBAProcessEvents
|
||||||
- Qt: Add preset for DualShock 4
|
- Qt: Add preset for DualShock 4
|
||||||
|
|
|
@ -109,6 +109,14 @@ static inline ssize_t SocketRecv(Socket socket, void* buffer, size_t size) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int SocketClose(Socket socket) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
return closesocket(socket) == 0;
|
||||||
|
#else
|
||||||
|
return close(socket) >= 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static inline Socket SocketOpenTCP(int port, const struct Address* bindAddress) {
|
static inline Socket SocketOpenTCP(int port, const struct Address* bindAddress) {
|
||||||
Socket sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
Socket sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if (SOCKET_FAILED(sock)) {
|
if (SOCKET_FAILED(sock)) {
|
||||||
|
@ -145,7 +153,7 @@ static inline Socket SocketOpenTCP(int port, const struct Address* bindAddress)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
close(sock);
|
SocketClose(sock);
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
return sock;
|
return sock;
|
||||||
|
@ -183,7 +191,7 @@ static inline Socket SocketConnectTCP(int port, const struct Address* destinatio
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
close(sock);
|
SocketClose(sock);
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
return sock;
|
return sock;
|
||||||
|
@ -217,10 +225,6 @@ static inline Socket SocketAccept(Socket socket, struct Address* address) {
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int SocketClose(Socket socket) {
|
|
||||||
return close(socket) >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int SocketSetBlocking(Socket socket, bool blocking) {
|
static inline int SocketSetBlocking(Socket socket, bool blocking) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
u_long unblocking = !blocking;
|
u_long unblocking = !blocking;
|
||||||
|
|
Loading…
Reference in New Issue