From 26ffda7a5d4698bb1d59e2246aa35ac8ecbf4022 Mon Sep 17 00:00:00 2001 From: starcalc Date: Thu, 6 Sep 2018 21:44:46 +0200 Subject: [PATCH] Add new file --- run.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 run.py diff --git a/run.py b/run.py new file mode 100644 index 0000000..1fedf8b --- /dev/null +++ b/run.py @@ -0,0 +1,22 @@ +#!/usr/bin/python3 + +import RPi.GPIO as GPIO +import time +from datetime import datetime +import socket +GPIO.setmode(GPIO.BCM) +GPIO.setup(17, GPIO.OUT) +GPIO.output(17,GPIO.HIGH) +serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) +serversocket.bind(('192.168.1.1', 8000)) +serversocket.listen(5) # become a server socket, maximum 5 connections +print (round(datetime.utcnow().timestamp() * 1000)) +# while True: +connection, address = serversocket.accept() +buf = connection.recv(64) +if len(buf) > 0: + print (buf) +print (round(datetime.utcnow().timestamp() * 1000)) +serversocket.close() +GPIO.output(17,GPIO.LOW)