diff options
author | Eric Andersen | 2002-07-03 11:51:44 +0000 |
---|---|---|
committer | Eric Andersen | 2002-07-03 11:51:44 +0000 |
commit | 0b31586c7113b9b26ca0aeee9247a831b55b308c (patch) | |
tree | 7071145eeeea4dd92d18e05fce6d8e710dc67d52 /networking/wget.c | |
parent | 51b8bd68bb22b1cc5d95e418813c2f08a194ec2b (diff) | |
download | busybox-0b31586c7113b9b26ca0aeee9247a831b55b308c.zip busybox-0b31586c7113b9b26ca0aeee9247a831b55b308c.tar.gz |
A patch from Bart Visscher <magick@linux-fan.com> to add an
xconnect helper routine which does:
-address and port resolving
-tries to connect to all resolved addresses until connected
-uses getaddrinfo, so works for IPv6 too
This patch also ports rdate, telnet, and wget to use the new
xconnect function. Thanks Bart!
Diffstat (limited to 'networking/wget.c')
-rw-r--r-- | networking/wget.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/networking/wget.c b/networking/wget.c index 6974c70..c620021 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -563,24 +563,16 @@ void parse_url(char *url, struct host_info *h) 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()"); @@ -826,7 +818,7 @@ progressmeter(int flag) * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: wget.c,v 1.49 2002/05/14 23:36:45 sandman Exp $ + * $Id: wget.c,v 1.50 2002/07/03 11:51:44 andersen Exp $ */ |