38 #include <sys/socket.h>
39 #include <netinet/in.h>
56 static struct sockaddr_in sin;
64 if (sin.sin_family == 0) {
65 if ((sp = getservbyname(
"biff",
"udp")) == 0) {
66 msg_warn(
"service not found: biff/udp");
69 if ((hp = gethostbyname(
"localhost")) == 0) {
70 msg_warn(
"host not found: localhost");
73 if ((
int) hp->h_length > (
int)
sizeof(sin.sin_addr)) {
74 msg_warn(
"bad address size %d for localhost", hp->h_length);
77 sin.sin_family = hp->h_addrtype;
78 sin.sin_port = sp->s_port;
79 memcpy((
void *) &sin.sin_addr, hp->h_addr_list[0], hp->h_length);
86 if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
96 if (sendto(sock, text, len, 0, (
struct sockaddr *) &sin,
sizeof(sin)) != len)
void msg_warn(const char *fmt,...)
void biff_notify(const char *text, ssize_t len)
int close_on_exec(int fd, int on)