Change interface to bb_lookup_host, dont try and set port inside this

function as there is no gracefull way of handling failures.
Rename bb_getport to bb_lookup_port, allow a default port to be
specified so it always returns a correct value.
Modify ftpgetput/rdate/wget to use the new interface.
wget/rdate now use etc/services with a falback default value.
This commit is contained in:
Glenn L McGrath
2003-12-20 01:47:18 +00:00
parent 03d8091859
commit ffccf6eb5d
6 changed files with 39 additions and 49 deletions

View File

@ -570,8 +570,6 @@ static void cookmode(void)
extern int telnet_main(int argc, char** argv)
{
char *host;
char *port;
int len;
struct sockaddr_in s_in;
#ifdef USE_POLL
@ -597,12 +595,12 @@ extern int telnet_main(int argc, char** argv)
G.termios_raw = G.termios_def;
cfmakeraw(&G.termios_raw);
if (argc < 2) bb_show_usage();
port = (argc > 2)? argv[2] : "23";
if (argc < 2)
bb_show_usage();
host = argv[1];
bb_lookup_host(&s_in, argv[1]);
s_in.sin_port = bb_lookup_port((argc == 3) ? argv[2] : "telnet", 23);
bb_lookup_host(&s_in, host, port);
G.netfd = xconnect(&s_in);
setsockopt(G.netfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one);