--- telnet.c.old	Wed Jul  4 08:17:15 2001
+++ telnet.c	Wed Jul  4 08:17:24 2001
@@ -34,6 +34,9 @@

 #include <errno.h>

+#if defined(WIN32)
+#include <conio.h>
+#endif
 #if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
 #include <winsock.h>
 #include <time.h>
@@ -1041,6 +1044,13 @@
   ssize_t nread;
   struct TELNET *tn;

+#if defined(WIN32)
+  struct timeval timer1;
+
+  timer1.tv_sec = 0;
+  timer1.tv_usec = 500;
+#endif
+
   code = init_telnet(conn);
   if(code)
     return code;
@@ -1053,28 +1063,46 @@

   FD_ZERO (&readfd);		/* clear it */
   FD_SET (sockfd, &readfd);
+#if !defined(WIN32)
   FD_SET (1, &readfd);
-
+#endif
   keepfd = readfd;

   while (keepon) {
     readfd = keepfd;		/* set this every lap in the loop */
-
+#if defined(WIN32)
+	switch (select (sockfd + 1, &readfd, NULL, NULL, &timer1)) {
+#else
     switch (select (sockfd + 1, &readfd, NULL, NULL, NULL)) {
+#endif
     case -1:			/* error, stop reading */
       keepon = FALSE;
       continue;
+#if !defined(WIN32)
     case 0:			/* timeout */
       break;
+#endif
     default:			/* read! */
+#if defined(WIN32)
+	  nread = 0;
+	  if (kbhit()) {
+#else
       if(FD_ISSET(1, &readfd)) { /* read from stdin */
+#endif
         unsigned char outbuf[2];
         int out_count = 0;
         size_t bytes_written;
         char *buffer = buf;
-
+#if defined (WIN32)
+		buf[nread] = getch();
+		nread++;
+		if (kbhit()) {
+		  buf[nread] = getch();
+		  nread++;
+		}
+#else
         nread = read(1, buf, 255);
-
+#endif
         while(nread--) {
           outbuf[0] = *buffer++;
           out_count = 1;


