Created
October 1, 2016 14:03
-
-
Save olivierlemoal/7f0070e4b06c55940363268c6c93a523 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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