summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2014-12-20 20:17:05 +0100
committerFlorian Jung <flo@windfisch.org>2014-12-20 20:17:05 +0100
commit0fbdbb674022239356a0da7aae7ea91d91662c9a (patch)
treea9e2290a991b682cd914d134cb2c52acf0a1fec1
parentee3b8a40bb74422a1319f551ab4a42f63ea51678 (diff)
server
-rw-r--r--server.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/server.py b/server.py
index 7fca945..6fc2814 100644
--- a/server.py
+++ b/server.py
@@ -1,4 +1,46 @@
import cv2
+import os
+import socket
+import sys
+
+server_address = '/home/flo/uds_socket'
+try:
+ os.unlink(server_address)
+except OSError:
+ if os.path.exists(server_address):
+ raise
+
+# Create a UDS socket
+sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+
+# Bind the socket to the port
+print >>sys.stderr, 'starting up on %s' % server_address
+sock.bind(server_address)
+
+# Listen for incoming connections
+sock.listen(1)
+
+while True:
+ # Wait for a connection
+ print >>sys.stderr, 'waiting for a connection'
+ connection, client_address = sock.accept()
+ try:
+ print >>sys.stderr, 'connection from', client_address
+
+ # Receive the data in small chunks and retransmit it
+ while True:
+ data = connection.recv(16)
+ print >>sys.stderr, 'received "%s"' % data
+ if data:
+ print >>sys.stderr, 'sending data back to the client'
+ connection.sendall(data)
+ else:
+ print >>sys.stderr, 'no more data from', client_address
+ break
+
+ finally:
+ # Clean up the connection
+ connection.close()
cap = cv2.VideoCapture("/home/flo/outvid2.avi")
while True: