diff options
author | Matt Kraai | 2001-10-01 17:52:14 +0000 |
---|---|---|
committer | Matt Kraai | 2001-10-01 17:52:14 +0000 |
commit | c9fc633f9ed09143a63f62f26b0afb619a31273c (patch) | |
tree | f2ddb19d9aa993a616c69dff143f5bad18205076 | |
parent | 524fcb9e01b6aa48334bfd6470045a0f3591cae9 (diff) | |
download | busybox-c9fc633f9ed09143a63f62f26b0afb619a31273c.zip busybox-c9fc633f9ed09143a63f62f26b0afb619a31273c.tar.gz |
Use port 37 by default.
-rw-r--r-- | rdate.c | 12 | ||||
-rw-r--r-- | util-linux/rdate.c | 12 |
2 files changed, 12 insertions, 12 deletions
@@ -46,17 +46,17 @@ static time_t askremotedate(const char *host) int fd; h = xgethostbyname(host); /* get the IP addr */ + memcpy(&s_in.sin_addr, h->h_addr, sizeof(s_in.sin_addr)); + + s_in.sin_port = htons(37); /* find port # */ + if ((tserv = getservbyname("time", "tcp")) != NULL) + s_in.sin_port = tserv->s_port; - if ((tserv = getservbyname("time", "tcp")) == NULL) /* find port # */ - perror_msg_and_die("time"); + s_in.sin_family = AF_INET; if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* get net connection */ perror_msg_and_die("socket"); - memcpy(&s_in.sin_addr, h->h_addr, sizeof(s_in.sin_addr)); - s_in.sin_port= tserv->s_port; - s_in.sin_family = AF_INET; - if (connect(fd, (struct sockaddr *)&s_in, sizeof(s_in)) < 0) /* connect to time server */ perror_msg_and_die("%s", host); diff --git a/util-linux/rdate.c b/util-linux/rdate.c index 50be4de..04a7612 100644 --- a/util-linux/rdate.c +++ b/util-linux/rdate.c @@ -46,17 +46,17 @@ static time_t askremotedate(const char *host) int fd; h = xgethostbyname(host); /* get the IP addr */ + memcpy(&s_in.sin_addr, h->h_addr, sizeof(s_in.sin_addr)); + + s_in.sin_port = htons(37); /* find port # */ + if ((tserv = getservbyname("time", "tcp")) != NULL) + s_in.sin_port = tserv->s_port; - if ((tserv = getservbyname("time", "tcp")) == NULL) /* find port # */ - perror_msg_and_die("time"); + s_in.sin_family = AF_INET; if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* get net connection */ perror_msg_and_die("socket"); - memcpy(&s_in.sin_addr, h->h_addr, sizeof(s_in.sin_addr)); - s_in.sin_port= tserv->s_port; - s_in.sin_family = AF_INET; - if (connect(fd, (struct sockaddr *)&s_in, sizeof(s_in)) < 0) /* connect to time server */ perror_msg_and_die("%s", host); |