1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains the ZhmStat() function.
4 * Created by: Marc Horowitz
8 * Copyright (c) 1996 by the Massachusetts Institute of Technology.
9 * For copying and distribution information, see the file
14 #include <sys/socket.h>
16 #ifndef INADDR_LOOPBACK
17 #define INADDR_LOOPBACK 0x7f000001
20 Code_t ZhmStat(hostaddr, notice)
21 struct in_addr *hostaddr;
25 struct sockaddr_in sin;
31 (void) memset((char *)&sin, 0, sizeof(struct sockaddr_in));
33 sp = getservbyname(HM_SVCNAME, "udp");
35 sin.sin_port = (sp) ? sp->s_port : HM_SVC_FALLBACK;
36 sin.sin_family = AF_INET;
39 sin.sin_addr = *hostaddr;
41 sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
43 (void) memset((char *)&req, 0, sizeof(req));
46 req.z_class = HM_STAT_CLASS;
47 req.z_class_inst = HM_STAT_CLIENT;
48 req.z_opcode = HM_GIMMESTATS;
51 req.z_default_format = "";
52 req.z_message_len = 0;
54 if ((code = ZSetDestAddr(&sin)) != ZERR_NONE)
57 if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE)
60 /* Wait up to ten seconds for a response. */
62 FD_SET(ZGetFD(), &readers);
65 code = select(ZGetFD() + 1, &readers, NULL, NULL, &tv);
66 if (code < 0 && errno != EINTR)
68 if (code == 0 || (code < 0 && errno == EINTR) || ZPending() == 0)
71 return(ZReceiveNotice(notice, (struct sockaddr_in *) 0));