diff --git a/webbench-1.5/socket.c b/webbench-1.5/socket.c index b7af54a..16e38b9 100644 --- a/webbench-1.5/socket.c +++ b/webbench-1.5/socket.c @@ -9,10 +9,10 @@ SCCS ID: @(#)socket.c 1.5 4/1/94 programmer: Virginia Tech Computing Center compiler: DEC RISC C compiler (Ultrix 4.1) - environment: DEC Ultrix 4.3 + environment: DEC Ultrix 4.3 description: UNIX sockets code. ***********************************************************************/ - + #include #include #include @@ -32,7 +32,7 @@ int Socket(const char *host, int clientPort) unsigned long inaddr; struct sockaddr_in ad; struct hostent *hp; - + memset(&ad, 0, sizeof(ad)); ad.sin_family = AF_INET; @@ -47,12 +47,15 @@ int Socket(const char *host, int clientPort) memcpy(&ad.sin_addr, hp->h_addr, hp->h_length); } ad.sin_port = htons(clientPort); - + sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) return sock; if (connect(sock, (struct sockaddr *)&ad, sizeof(ad)) < 0) + { + close(sock); return -1; + } return sock; }