Bonjour
Le code qui suit écoute la première connexion qui ce fais mais dès que celle-ci est clause il ce termine.
Comme le modifier pour qu’au lieu de ce couper il attend qu’une nouvelle connexion arrive ?
# coding: utf-8
import RPi.GPIO as GPIO
import time
import sys
import urllib
import socket
import os
socket_path = '/tmp/uv4l.socket'
try:
os.unlink(socket_path)
except OSError:
if os.path.exists(socket_path):
raise
s = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)
print 'socket_path: %s' % socket_path
s.bind(socket_path)
s.listen(1)
while True:
print 'awaiting connection...'
connection, client_address = s.accept()
print 'client_address %s' % client_address
try:
print 'established connection with', client_address
while True:
data = connection.recv(16)
print data
print 'received message"%s"' % data
#time.sleep(0.01)
action = int(data)
if action == 38:
print '38'
elif action == 40:
print '40'
finally:
connection.close()
print 'Connexion socket close'
break
+0
-0