1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-08-05 20:55:47 +03:00

add portable LIBSSH2_SOCKET_CLOSE() macro

Add `LIBSSH2_SOCKET_CLOSE()` to the public `libssh2.h` header, for user
code. It translates to `closesocket()` on Windows and `close()` on other
platforms.

Use it in example code.

It makes them more readable by reducing the number of `_WIN32` guards.

Closes #1278
This commit is contained in:
Viktor Szakats
2023-12-08 02:22:48 +00:00
parent 46333adfb8
commit 28dbf01667
25 changed files with 36 additions and 138 deletions

View File

@@ -143,9 +143,11 @@ typedef long long libssh2_int64_t;
#ifdef _WIN32
typedef SOCKET libssh2_socket_t;
#define LIBSSH2_INVALID_SOCKET INVALID_SOCKET
#define LIBSSH2_SOCKET_CLOSE(s) closesocket(s)
#else /* !_WIN32 */
typedef int libssh2_socket_t;
#define LIBSSH2_INVALID_SOCKET -1
#define LIBSSH2_SOCKET_CLOSE(s) close(s)
#endif /* _WIN32 */
/*