Update socket wrapper

This commit is contained in:
Zhi Guan
2026-06-13 15:09:45 +08:00
parent 23375d1fa3
commit 19725f3c54
15 changed files with 406 additions and 261 deletions

View File

@@ -9,7 +9,6 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <gmssl/mem.h>
@@ -53,25 +52,6 @@ static const char *help =
"\n";
static int set_socket_nonblocking(tls_socket_t sock)
{
#ifdef WIN32
u_long mode = 1;
if (ioctlsocket(sock, FIONBIO, &mode) != 0) {
error_print();
return -1;
}
#else
int flags;
if ((flags = fcntl(sock, F_GETFL)) < 0
|| fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0) {
error_print();
return -1;
}
#endif
return 1;
}
static int do_handshake_select(TLS_CONNECT *conn)
{
int ret;
@@ -551,7 +531,7 @@ bad:
goto end;
}
if (set_socket_nonblocking(conn_sock) != 1) {
if (tls_socket_set_nonblocking(conn_sock, 1) != 1) {
error_print();
goto end;
}