1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-28 01:41:49 +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

@ -288,11 +288,7 @@ shutdown:
if(sock != LIBSSH2_INVALID_SOCKET) {
shutdown(sock, 2);
#ifdef _WIN32
closesocket(sock);
#else
close(sock);
#endif
LIBSSH2_SOCKET_CLOSE(sock);
}
fprintf(stderr, "all done\n");