mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
Update socket wrapper
This commit is contained in:
@@ -89,6 +89,12 @@ bad:
|
||||
fprintf(stderr, "%s: '-in' option required\n", prog);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tls_socket_lib_init() != 1) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(hp = gethostbyname(host))) {
|
||||
//herror("tls12_client: '-host' invalid"); // herror() not in winsock2, use WSAGetLastError() instead
|
||||
goto end;
|
||||
@@ -102,12 +108,12 @@ bad:
|
||||
server.sin_port = htons(port);
|
||||
|
||||
|
||||
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
//fprintf(stderr, "%s: open socket error : %s\n", prog, strerror(errno)); //FIXME: WIN32 use WSAGetLastError()
|
||||
if (tls_socket_create(&sock, AF_INET, SOCK_STREAM, 0) != 1) {
|
||||
fprintf(stderr, "%s: create socket error\n", prog);
|
||||
goto end;
|
||||
}
|
||||
if (connect(sock, (struct sockaddr *)&server , sizeof(server)) < 0) {
|
||||
//fprintf(stderr, "%s: connect error : %s\n", prog, strerror(errno)); //
|
||||
if (tls_socket_connect(sock, &server) != 1) {
|
||||
fprintf(stderr, "%s: socket connect error\n", prog);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user