#!/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)