diff options
Diffstat (limited to 'util-linux/rdate.c')
-rw-r--r-- | util-linux/rdate.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/util-linux/rdate.c b/util-linux/rdate.c index 8d156cc..a822f42 100644 --- a/util-linux/rdate.c +++ b/util-linux/rdate.c @@ -47,17 +47,16 @@ static void socket_timeout(int sig) static time_t askremotedate(const char *host) { unsigned long int nett, localt; - const char *port="37"; + struct sockaddr_in addr s_in; int fd; - if (getservbyname("time", "tcp") != NULL) - port="time"; + bb_lookup_host(&s_in, host, "time"); /* Add a timeout for dead or non accessable servers */ alarm(10); signal(SIGALRM, socket_timeout); - fd = xconnect(host, port); + fd = xconnect(s_in); if (safe_read(fd, (void *)&nett, 4) != 4) /* read time from server */ bb_error_msg_and_die("%s did not send the complete time", host); |