I'm trying to write a daemon in C that runs under (x)inetd that
communicates over UDP. I'm trying to write a simple DNS server that
returns the same IP for every query it receives. Things work just
fine reading the request, but when I try to write(2) the response, it
returns -1 with errno 89: "Destination address required". This seems
to indicate the wrong setting on a socket. Here's my xinetd config
paragraph:
------------------------- Achilles tendon - cut here -------------------------
service domain
{
port = 53
protocol = udp
socket_type = dgram
wait = yes
only_from = 127.0.0.1
user = root
server = /usr/local/sbin/dns
log_on_failure += USERID
disable = no
}
------------------------- Achilles tendon - cut here -------------------------
The write that's failing is the first one I'm calling, and it takes
place less than a second after the request comes in. I verified this
with the following program:
------------------------- Achilles tendon - cut here -------------------------
main() {
int err;
char *buf = "hello";
openlog("dns", LOG_PID, LOG_DAEMON);
if ((err = write(1, buf, 1)) != 1)
syslog(LOG_ERR, "write returned %d: errno %d: %s",
err, errno, strerror(errno));
closelog();
return 0;
}
------------------------- Achilles tendon - cut here -------------------------
If I run that from the command line, it prints an "h". From xinetd,
it logs:
write returned -1: errno 89: Destination address required
What am I doing wrong?
I suppose I could rewrite this thing to act as a standalone daemon,
but that's more work & a lot of refresher reading on socket programming.
If it matters, this is CentOS (RedHat) linux with a 2.4 kernel.
--
Ben "Obi-Wan" Hollingsworth ob****@jedi.com
The stuff of earth competes for the allegiance I owe only to the
Giver of all good things, so if I stand, let me stand on the
promise that You will pull me through. -- Rich Mullins
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----