Skip to content

Instantly share code, notes, and snippets.

@olivierlemoal
Created October 1, 2016 14:03
Show Gist options
  • Save olivierlemoal/7f0070e4b06c55940363268c6c93a523 to your computer and use it in GitHub Desktop.
Save olivierlemoal/7f0070e4b06c55940363268c6c93a523 to your computer and use it in GitHub Desktop.
import socket
import time
IP = "127.0.0.1"
PORT = 9220
def receiv():
data = None
try:
data = s.recv(1024)
while True:
data += s.recv(1024)
except BlockingIOError:
pass
if data:
print(data.decode("ascii"))
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((IP, PORT))
s.setblocking(False)
time.sleep(0.5)
receiv()
s.sendall(b"PLOP\n")
receiv()
s.shutdown(socket.SHUT_WR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment