diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-07-03 11:51:44 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-07-03 11:51:44 +0000 |
commit | 0b31586c7113b9b26ca0aeee9247a831b55b308c (patch) | |
tree | 7071145eeeea4dd92d18e05fce6d8e710dc67d52 /networking/wget.c | |
parent | 51b8bd68bb22b1cc5d95e418813c2f08a194ec2b (diff) | |
download | busybox-w32-0b31586c7113b9b26ca0aeee9247a831b55b308c.tar.gz busybox-w32-0b31586c7113b9b26ca0aeee9247a831b55b308c.tar.bz2 busybox-w32-0b31586c7113b9b26ca0aeee9247a831b55b308c.zip |
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 6974c70a8..c6200219b 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -563,24 +563,16 @@ void parse_url(char *url, struct host_info *h) | |||
563 | 563 | ||
564 | FILE *open_socket(char *host, int port) | 564 | FILE *open_socket(char *host, int port) |
565 | { | 565 | { |
566 | struct sockaddr_in s_in; | ||
567 | struct hostent *hp; | ||
568 | int fd; | 566 | int fd; |
569 | FILE *fp; | 567 | FILE *fp; |
568 | char port_str[10]; | ||
570 | 569 | ||
571 | memset(&s_in, 0, sizeof(s_in)); | 570 | snprintf(port_str, sizeof(port_str), "%d", port); |
572 | s_in.sin_family = AF_INET; | 571 | fd=xconnect(host, port_str); |
573 | hp = xgethostbyname(host); | ||
574 | memcpy(&s_in.sin_addr, hp->h_addr_list[0], hp->h_length); | ||
575 | s_in.sin_port = htons(port); | ||
576 | 572 | ||
577 | /* | 573 | /* |
578 | * Get the server onto a stdio stream. | 574 | * Get the server onto a stdio stream. |
579 | */ | 575 | */ |
580 | if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) | ||
581 | perror_msg_and_die("socket()"); | ||
582 | if (connect(fd, (struct sockaddr *) &s_in, sizeof(s_in)) < 0) | ||
583 | perror_msg_and_die("connect(%s)", host); | ||
584 | if ((fp = fdopen(fd, "r+")) == NULL) | 576 | if ((fp = fdopen(fd, "r+")) == NULL) |
585 | perror_msg_and_die("fdopen()"); | 577 | perror_msg_and_die("fdopen()"); |
586 | 578 | ||
@@ -826,7 +818,7 @@ progressmeter(int flag) | |||
826 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 818 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
827 | * SUCH DAMAGE. | 819 | * SUCH DAMAGE. |
828 | * | 820 | * |
829 | * $Id: wget.c,v 1.49 2002/05/14 23:36:45 sandman Exp $ | 821 | * $Id: wget.c,v 1.50 2002/07/03 11:51:44 andersen Exp $ |
830 | */ | 822 | */ |
831 | 823 | ||
832 | 824 | ||