Index: trunk/rtcm3torinex/rtcm3torinex.c
===================================================================
--- trunk/rtcm3torinex/rtcm3torinex.c	(revision 1088)
+++ trunk/rtcm3torinex/rtcm3torinex.c	(revision 1091)
@@ -1,5 +1,5 @@
 /*
   Converter for RTCM3 data to RINEX.
-  $Id: rtcm3torinex.c,v 1.29 2008/07/22 15:15:51 stoecker Exp $
+  $Id: rtcm3torinex.c,v 1.30 2008/09/01 07:47:15 stoecker Exp $
   Copyright (C) 2005-2008 by Dirk Stöcker <stoecker@alberding.eu>
 
@@ -1532,5 +1532,5 @@
 
 #ifndef NO_RTCM3_MAIN
-static char datestr[]     = "$Date: 2008/07/22 15:15:51 $";
+static char datestr[]     = "$Date: 2008/09/01 07:47:15 $";
 
 /* The string, which is send as agent in HTTP request */
@@ -1887,4 +1887,22 @@
 }
 
+#ifndef WINDOWSVERSION
+static void WaitMicro(int mic)
+{
+  struct timeval tv;
+  tv.tv_sec = mic/1000000;
+  tv.tv_usec = mic%1000000;
+#ifdef DEBUG
+  fprintf(stderr, "Waiting %d micro seconds\n", mic);
+#endif
+  select(0, 0, 0, 0, &tv);
+}
+#else /* WINDOWSVERSION */
+void WaitMicro(int mic)
+{
+   Sleep(mic/1000);
+}
+#endif /* WINDOWSVERSION */
+
 #define ALARMTIME   (2*60)
 
@@ -2192,4 +2210,5 @@
                   if(init)
                   {
+                    int z;
                     if(u < -30000 && sn > 30000) sn -= 0xFFFF;
                     if(ssrc != w || ts > v)
@@ -2199,5 +2218,6 @@
                     }
                     if(u > sn) /* don't show out-of-order packets */
-                      fwrite(buf+12, (size_t)i-12, 1, stdout);
+                    for(z = 12; z < i && !stop; ++z)
+                      HandleByte(&Parser, (unsigned int) buf[z]);
                   }
                   sn = u; ts = v; ssrc = w; init = 1;
@@ -2324,5 +2344,11 @@
         while(!stop && (numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) != -1)
         {
-          alarm(ALARMTIME);
+          if(numbytes > 0)
+            alarm(ALARMTIME);
+          else
+          {
+            WaitMicro(100);
+            continue;
+          }
           if(!k)
           {
@@ -2353,5 +2379,5 @@
               if(i < numbytes-l)
                 chunkymode = 1;
-	    }
+            }
             else if(numbytes < 12 || strncmp("ICY 200 OK\r\n", buf, 12))
             {
