Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Mar 2000 21:31:06 +0000
From:      David Malone <dwmalone@maths.tcd.ie>
To:        hackers@freebsd.org
Subject:   T/TCP friendly inetd change?
Message-ID:   <200003162131.aa50415@salmon.maths.tcd.ie>

next in thread | raw e-mail | index | archive | help
I was reading a little about T/TCP in Steven's book, and it occured
to me that some of inetd's small services would be ideal candidates
for T/TCP. (auth, time and daytime in particular).

According to Stevens, the main thing you need to do to make a server
T/TCP firendly is use the MSG_EOF flag when you send the last block
of data to that socket. For each of these services, which only
write a single block of data, this involves just changing:

	write(s, buf, len);

to:

	send(s, buf, len, MSG_EOF);

I've tried this over my slip link and it does seem to reduce the
number of packets sent by 2 for telnetting to the daytime port. I
also had a look at fetch (the only thing in the tree which uses
MSG_EOF at the moment), which has an option for turning off the
MSG_EOF stuff 'cos some buggy http servers don't like half closed
connections. I don't think this applies in this case 'cos we're
on the server side - not the client side, and the client expects
an EOF anyway.

Would this be an acceptable patch to inetd? It would be nice to
encourage the use of T/TCP within FreeBSD, as we seem to be the
only people who have it ;-)

	David.

--- builtins.c	2000/03/11 11:28:07	1.19
+++ builtins.c	2000/03/16 21:20:02
@@ -219,7 +219,7 @@
 	clock = time((time_t *) 0);
 
 	(void) sprintf(buffer, "%.24s\r\n", ctime(&clock));
-	(void) write(s, buffer, strlen(buffer));
+	(void) send(s, buffer, strlen(buffer), MSG_EOF);
 }
 
 /*
@@ -320,7 +320,7 @@
 		syslog(LOG_ERR, "asprintf: %m");
 		exit(EX_OSERR);
 	}
-	write(s, p, strlen(p));
+	send(s, p, strlen(p), MSG_EOF);
 	free(p);
 
 	exit(0);
@@ -602,7 +602,7 @@
 		syslog(LOG_ERR, "asprintf: %m");
 		exit(EX_OSERR);
 	}
-	write(s, p, strlen(p));
+	send(s, p, strlen(p), MSG_EOF);
 	free(p);
 	
 	exit(0);
@@ -664,7 +664,7 @@
 	unsigned long result;
 
 	result = machtime();
-	(void) write(s, (char *) &result, sizeof(result));
+	(void) send(s, (char *) &result, sizeof(result), MSG_EOF);
 }
 
 /*


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi? <200003162131.aa50415>