all repos — mgba @ b1691c952793d9a290c3aaab3bcdeffd75fadb07

mGBA Game Boy Advance Emulator

Util: Use closesocket on Windows
Jeffrey Pfau jeffrey@endrift.com
Sat, 05 Mar 2016 11:33:36 -0800
commit

b1691c952793d9a290c3aaab3bcdeffd75fadb07

parent

d3a637fbae984ba5f56f87a3821565178ff1dbfb

2 files changed, 11 insertions(+), 6 deletions(-)

jump to
M CHANGESCHANGES

@@ -18,6 +18,7 @@ - Qt: Initialize m_useBios

- GBA Serialize: Fix memory corruption bug in GBAExtdataSerialize - GBA Serialize: Fix loading savegames from savestates - All: Fix several file handle leaks + - Util: Use closesocket on Windows Misc: - GBA: Slightly optimize GBAProcessEvents - Qt: Add preset for DualShock 4
M src/util/socket.hsrc/util/socket.h

@@ -109,6 +109,14 @@ return read(socket, buffer, size);

#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) { Socket sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (SOCKET_FAILED(sock)) {

@@ -145,7 +153,7 @@ err = bind(sock, (const struct sockaddr*) &bindInfo, sizeof(bindInfo));

#endif } if (err) { - close(sock); + SocketClose(sock); return INVALID_SOCKET; } return sock;

@@ -183,7 +191,7 @@ #endif

} if (err) { - close(sock); + SocketClose(sock); return INVALID_SOCKET; } return sock;

@@ -215,10 +223,6 @@ return accept(socket, (struct sockaddr*) &addrInfo, &len);

#endif } return INVALID_SOCKET; -} - -static inline int SocketClose(Socket socket) { - return close(socket) >= 0; } static inline int SocketSetBlocking(Socket socket, bool blocking) {