Index: py-tcpmultiplexer/TCPMultiplexer.py
===================================================================
--- py-tcpmultiplexer/TCPMultiplexer.py	(revision 324)
+++ py-tcpmultiplexer/TCPMultiplexer.py	(revision 325)
@@ -24,11 +24,11 @@
 DEFAULT_CONFIG = 'streams.yaml'
 DEFAULT_DOCUMENTROOT = './htdocs'
-DEFAULT_TIMEOUT = 2
+DEFAULT_TIMEOUT = None
 
 
 # URL : TARGET
 DEFAULT_STREAMS = {
-  '/cam1/video' : 'http://172.16.0.67:8080/videofeed',
-  '/cam1/audio' : 'http://172.16.0.67:8080/audio.wav',
+#  '/cam1/video' : 'http://172.16.0.67:8080/videofeed',
+#  '/cam1/audio' : 'http://172.16.0.67:8080/audio.wav',
   }
 
@@ -38,9 +38,11 @@
 dataheader = dict()
 urldata = dict()
+stream_running = dict()
 running = True
 recv_threads = []
 document_root = None
-
-logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+recv_timeout = None
+
+logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
 
 class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
@@ -58,5 +60,5 @@
 
     def handle(self):
-        global running, dataheader, document_root, urlheader, urldata
+        global running, dataheader, document_root, stream_running, urlheader, urldata
         # self.request is the TCP socket connected to the client
         self.data = self.request.recv(1024).strip()
@@ -69,5 +71,5 @@
           if urlid == '/':
             self.request.send("HTTP/1.1 200 OK\n\n<html><head><title>Overview</title></head><body><h3>Streams</h3><ul>")
-            for urlid in sorted(urldata.keys()):
+            for urlid in filter(lambda x: stream_running[x], stream_running.keys()):
               self.request.send('<li><a href="%(urlid)s">%(urlid)s</a></li>' % {'urlid': urlid})
             self.request.send("</ul><h3>Files</h3><ul>")
@@ -91,5 +93,6 @@
                 self.request.send(urldata[urlid][self].pop(0))
           elif os.path.isfile(document_file):
-            self.request.send('HTTP/1.1 200 OK\n\n' + open(document_file,'r').read())
+            data = open(document_file,'r').read()
+            self.request.send('HTTP/1.1 200 OK\nContent-Length: %s\n\n%s' % (len(data),data))
           else:
             self.request.send("HTTP/1.1 404 NOT FOUND\nContent-Type: text/html\n\n<h1>404</h1>The page '%s' does not exists" % urlid)
@@ -102,14 +105,15 @@
 def get_data(url, urlid, *args):
   """ Fetch the DATA from the WAV or MJPEG Stream """
-  global running, dataheader, urlheader, urldata
+  global running, dataheader, urlheader, urldata, stream_running, recv_timeout
   logger = logging.getLogger('recv_id=' + urlid)
   # Fill buffers if needed
   logger.info("Starting thread '%s' (%s)", url, urlid)
   while running:
+    stream_running[urlid] = False
     urlheader[urlid] = None
     dataheader[urlid] = None
     urldata[urlid] = None
     try:
-      f = urllib2.urlopen(url)
+      f = urllib2.urlopen(url,timeout=recv_timeout)
       urlheader[urlid] = ''.join(f.info().headers)
       urldata[urlid] = dict()
@@ -161,10 +165,15 @@
       else:
         dataheader[urlid] = ''
-
       logger.info("Using dataheader of length %s", len(dataheader[urlid]))
 
+      # Main data loader
+      logger.info("Stream ready to serve")
+      stream_running[urlid] = True
+      recv_buffer_size = 1024 * 8
       while running:
-        data = f.read(10000)
-        # logger.debug("Received data chunk with length: %s", len(data))
+        data = f.read(recv_buffer_size)
+        if not len(data) == recv_buffer_size:
+          raise IOError("Connection corrupted, got '%s' instead of '%s'" % (len(data), recv_buffer_size))
+        logger.debug("Received data chunk with length: %s", len(data))
         for key in urldata[urlid].keys():
           urldata[urlid][key].append(data)
@@ -172,9 +181,7 @@
       #Enforce a connection reset
       logger.warning("URL reset '%s' (%s)", url, e)
-      del urlheader[urlid]
-      del dataheader[urlid]
-      del urldata[urlid]
+      stream_running[urlid] = False
       time.sleep(1)
-      continue
+      pass
   logger.info("Closing Thread '%s'", url)
 
@@ -193,5 +200,6 @@
 
   # Set the timeout
-  socket.setdefaulttimeout(args.timeout)
+  logging.info("Changing socket timeout from '%s' to '%s'", socket.getdefaulttimeout(), args.timeout)
+  recv_timeout = args.timeout
 
   # Inport streams
Index: py-tcpmultiplexer/htdocs/browser.html
===================================================================
--- py-tcpmultiplexer/htdocs/browser.html	(revision 324)
+++ py-tcpmultiplexer/htdocs/browser.html	(revision 325)
@@ -69,4 +69,8 @@
 <small>Source Code at: <a href="http://rickvanderzwet.nl/svn/personal/py-tcpmultiplexer/">http://rickvanderzwet.nl/svn/personal/py-tcpmultiplexer/</a></small>
 
+<p />
+Example stream creation using VLC from WebCam: <pre>vlc -I http v4l:///dev/video0 --sout='#transcode{vcodec=MJPG}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=0.0.0.0:9000/webcam}}'</pre>
+
+
 </body>
 </html>
