mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
Add socket wrapper
This commit is contained in:
@@ -12,18 +12,6 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef WIN32
|
||||
// FIMXE: socket related headers should be moved to tls.h
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/types.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include <gmssl/tls.h>
|
||||
#include <gmssl/error.h>
|
||||
|
||||
@@ -49,11 +37,7 @@ int tlcp_client_main(int argc, char *argv[])
|
||||
char *pass = NULL;
|
||||
struct hostent *hp;
|
||||
struct sockaddr_in server;
|
||||
#ifdef WIN32
|
||||
SOCKET sock;
|
||||
#else
|
||||
int sock;
|
||||
#endif
|
||||
tls_socket_t sock;
|
||||
TLS_CTX ctx;
|
||||
TLS_CONNECT conn;
|
||||
char buf[1024] = {0};
|
||||
@@ -206,11 +190,7 @@ bad:
|
||||
|
||||
|
||||
end:
|
||||
#ifdef WIN32
|
||||
closesocket(sock);
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
tls_socket_close(sock);
|
||||
tls_ctx_cleanup(&ctx);
|
||||
tls_cleanup(&conn);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user