Created
April 12, 2020 22:42
-
-
Save dhilst/1da0efe00ef64ba9a093d596e9457b20 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
# test with `nc -kl 3000` | |
# write to nc terminal to send data | |
import socket | |
import sys | |
try: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
print("Socket successfully created") | |
except socket.error as err: | |
print("socket creation failed with error %s" %(err)) | |
s.settimeout(3.0) | |
s.connect(("localhost", 3000)) | |
r = s.recv(1024) | |
print(r.decode('ascii')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment