diff options
-rw-r--r-- | desiredata/src/u_pdsend.c | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/desiredata/src/u_pdsend.c b/desiredata/src/u_pdsend.c index 82eb2c59..8bcf8880 100644 --- a/desiredata/src/u_pdsend.c +++ b/desiredata/src/u_pdsend.c @@ -45,32 +45,15 @@ int main(int argc, char **argv) { #ifdef MSW if (WSAStartup(version, &nobby)) sockerror("WSAstartup"); #endif - sockfd = socket(AF_INET, protocol, 0); - if (sockfd < 0) { - sockerror("socket()"); - return 1; - } + if (sockfd < 0) {sockerror("socket()"); return 1;} /* connect socket using hostname provided in command line */ server.sin_family = AF_INET; hp = gethostbyname(hostname); - if (hp == 0) { - fprintf(stderr, "%s: unknown host\n", hostname); - x_closesocket(sockfd); - return 1; - } + if (!hp) {fprintf(stderr, "%s: unknown host\n", hostname); x_closesocket(sockfd); return 1;} memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length); - - /* assign client port number */ server.sin_port = htons((unsigned short)portno); - - /* try to connect. */ - if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) < 0) { - sockerror("connect"); - x_closesocket(sockfd); - return 1; - } - + if (connect(sockfd, (struct sockaddr *)&server, sizeof(server))<0) {sockerror("connect"); x_closesocket(sockfd); return 1;} /* now loop reading stdin and sending it to socket */ while (1) { char buf[BUFSIZE], *bp; |