* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1983 Regents of the University of California.\n\
static char sccsid
[] = "@(#)talkd.c 5.1 (Berkeley) %G%";
* The top level of the daemon, the format is heavily borrowed
* from rwhod.c. Basically: find out who and where you are;
* disconnect all descriptors and ttys, and then endless
* loop on waiting for and processing requests
struct sockaddr_in sin
= { AF_INET
};
debugout
= (FILE *)fopen ("/usr/tmp/talkd.msgs", "w");
fprintf(stderr
, "Talkd : not super user\n");
gethostname(hostname
, sizeof (hostname
));
signal(SIGALRM
, timeout
);
cc
= recvfrom(0, (char *)&request
, sizeof (request
), 0,
if (cc
!= sizeof(request
)) {
if (cc
< 0 && errno
!= EINTR
)
if (debug
) print_request(&request
);
process_request(&request
, &response
);
/* can block here, is this what I want? */
cc
= sendto(sockt
, (char *) &response
,
sizeof (response
), 0, &request
.ctl_addr
,
sizeof (request
.ctl_addr
));
if (cc
!= sizeof(response
))
if (time(0) - lastmsgtime
>= MAXIDLE
)
* heuristic to detect if need to swap bytes
if (req
->ctl_addr
.sin_family
== ntohs(AF_INET
)) {
req
->id_num
= ntohl(req
->id_num
);
req
->pid
= ntohl(req
->pid
);
req
->addr
.sin_family
= ntohs(req
->addr
.sin_family
);
req
->ctl_addr
.sin_family
=
ntohs(req
->ctl_addr
.sin_family
);