[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [BusyBox] Use xconnect in rdate
From: Bart Visscher <magick () Linux-Fan ! com>
Date: 2002-04-28 9:01:32
[Download RAW message or body]
Changelog:
* change the connect procedure to use xconnect
["10-rdate.patch" (text/x-patch)]
diff -ru -X exclude -P busybox-new-0/util-linux/rdate.c busybox-new-1/util-linux/rdate.c
--- busybox-new-0/util-linux/rdate.c Wed Apr 24 22:23:12 2002
+++ busybox-new-1/util-linux/rdate.c Thu Apr 25 21:31:15 2002
@@ -39,26 +39,14 @@
static time_t askremotedate(const char *host)
{
- struct hostent *h;
- struct sockaddr_in s_in;
- struct servent *tserv;
unsigned long int nett, localt;
+ const char *port="37";
int fd;
- h = xgethostbyname(host); /* get the IP addr */
- memcpy(&s_in.sin_addr, h->h_addr, sizeof(s_in.sin_addr));
+ if (getservbyname("time", "tcp") != NULL)
+ port="time";
- s_in.sin_port = htons(37); /* find port # */
- if ((tserv = getservbyname("time", "tcp")) != NULL)
- s_in.sin_port = tserv->s_port;
-
- s_in.sin_family = AF_INET;
-
- if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* get net connection */
- perror_msg_and_die("socket");
-
- if (connect(fd, (struct sockaddr *)&s_in, sizeof(s_in)) < 0) /* connect to time server */
- perror_msg_and_die("%s", host);
+ fd = xconnect(host, port);
if (read(fd, (void *)&nett, 4) != 4) /* read time from server */
error_msg_and_die("%s did not send the complete time", host);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic