X-Git-Url: https://ruderich.org/simon/gitweb/?p=tlsproxy%2Ftlsproxy.git;a=blobdiff_plain;f=src%2Fconnection.c;h=b7b9d683d6e6840af314dc2d87a4a049f06aa050;hp=ed1bc63c6e030c5349f9d2aa46a179c8d60bf2f9;hb=19b4321866194060cfc28419d52531a924f1b986;hpb=a84000d1d2806c296bfc0fa4b505b5d5ef750715 diff --git a/src/connection.c b/src/connection.c index ed1bc63..b7b9d68 100644 --- a/src/connection.c +++ b/src/connection.c @@ -156,7 +156,7 @@ void handle_connection(int client_socket) { server_socket = connect_to_host(host, port); } - if (server_socket == -1) { + if (server_socket < 0) { LOG(WARNING, "failed to connect to server"); send_forwarding_failure(client_fd_write); goto out; @@ -816,12 +816,12 @@ static int connect_to_host(const char *hostname, const char *port) { server_socket = socket(server->ai_family, server->ai_socktype, server->ai_protocol); - if (server_socket == -1) { + if (server_socket < 0) { LOG_PERROR(DEBUG, "connect_to_host(): socket(), trying next"); continue; } - if (connect(server_socket, server->ai_addr, server->ai_addrlen) != -1) { + if (connect(server_socket, server->ai_addr, server->ai_addrlen) == 0) { break; } LOG_PERROR(DEBUG, "connect_to_host(): connect(), trying next");