Created
July 23, 2018 18:15
-
-
Save mkoskinen/3a6eeb17c68b7b4806d2cee11db5079c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import sys | |
globneck = 60 | |
globrot = 90 | |
stoploop = 0 | |
def listen(): | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
# Gather received data here | |
alldata = '' | |
# Bind the socket to the port | |
server_address = ('localhost', 15000) | |
sock.bind(server_address) | |
# Listen for incoming connections | |
sock.listen(1) | |
while True: | |
# Wait for a connection | |
connection, client_address = sock.accept() | |
try: | |
# Receive the data in small chunks and retransmit it | |
while True: | |
data = connection.recv(32) | |
if data: | |
alldata += data | |
else: | |
print '/bin/echo "alldata ' + alldata + '\n" >> /tmp/debuggia' | |
#eval(alldata) | |
#exec(alldata) | |
alldata = '' | |
break | |
finally: | |
# Clean up the connection | |
connection.shutdown(socket.SHUT_RDWR) // Titta hit!!! | |
connection.close() | |
listen() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment