Friday, March 13, 2009

MicroDNS and NanoDNS

I have been posting a small program for real programmers that is a simple DNS server that always returns the same IP reply to any query sent. I also have a version of this program for wanna-be programmers; this program is properly indented, has comments, descriptive variable names, and other things real programmers prefer to do without. It even gives usage information if incorrectly invoked. It is available at

However, if the comments and coding style of MicroDNS bothers you, I have managed to get rid of even more bloat from NanoDNS, and have the updated program posted here:

/*Placed in the public domain by Sam Trenholme*/
#include <arpa/inet.h>
#include <string.h>
#define Z struct sockaddr
#define Y sizeof(d)
int main(int a,char **b){int i;char q[512],p[17
socket(AF_INET,SOCK_DGRAM,0);struct sockaddr_in
d;bzero(&d,Y);d.sin_port=htons(53);*((int *)(p+
a,(Z*)&d,Y);socklen_t f=511;for(;;){i=recvfrom(
&d,Y);}}}return 0;}