- Include string.h to avoid compile warning about using bzero without
defining it - use herror() rather than perror() to give useful error messages (the *hostby*() functions set h_errno not errno) PR: docs/126031 Submitted by: gavin
This commit is contained in:
parent
163aac8adc
commit
c3a59abed8
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=32611
1 changed files with 3 additions and 1 deletions
|
@ -966,6 +966,7 @@ int connect(int s, const struct sockaddr *name, socklen_t namelen);
|
||||||
* Programmed by G. Adam Stanislav
|
* Programmed by G. Adam Stanislav
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
@ -1181,6 +1182,7 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen);
|
||||||
* June 19, 2001
|
* June 19, 2001
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -1582,7 +1584,7 @@ int main(int argc, char *argv[]) {
|
||||||
host = (argc > 1) ? (char *)argv[1] : "time.nist.gov";
|
host = (argc > 1) ? (char *)argv[1] : "time.nist.gov";
|
||||||
|
|
||||||
if ((he = gethostbyname(host)) == NULL) {
|
if ((he = gethostbyname(host)) == NULL) {
|
||||||
perror(host);
|
herror(host);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue