[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [BusyBox] Use xconnect in wget
From: Bart Visscher <magick () Linux-Fan ! com>
Date: 2002-04-28 9:05:35
[Download RAW message or body]
Changelog:
* change the connect procedure to use xconnect
["10-wget.patch" (text/x-patch)]
diff -ru -X exclude -P busybox-new-1/networking/wget.c busybox-new-0/networking/wget.c
--- busybox-new-1/networking/wget.c Wed Apr 24 22:23:12 2002
+++ busybox-new-0/networking/wget.c Thu Apr 25 21:40:51 2002
@@ -555,24 +555,16 @@
FILE *open_socket(char *host, int port)
{
- struct sockaddr_in s_in;
- struct hostent *hp;
int fd;
FILE *fp;
+ char port_str[10];
- memset(&s_in, 0, sizeof(s_in));
- s_in.sin_family = AF_INET;
- hp = xgethostbyname(host);
- memcpy(&s_in.sin_addr, hp->h_addr_list[0], hp->h_length);
- s_in.sin_port = htons(port);
+ snprintf(port_str, sizeof(port_str), "%d", port);
+ fd=xconnect(host, port_str);
/*
* Get the server onto a stdio stream.
*/
- if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- perror_msg_and_die("socket()");
- if (connect(fd, (struct sockaddr *) &s_in, sizeof(s_in)) < 0)
- perror_msg_and_die("connect(%s)", host);
if ((fp = fdopen(fd, "r+")) == NULL)
perror_msg_and_die("fdopen()");
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic