Skip to content

Instantly share code, notes, and snippets.

@tbhaxor
Created November 30, 2019 08:26
Show Gist options
  • Save tbhaxor/fcde73f67faf251f2ea22a46a3a461d4 to your computer and use it in GitHub Desktop.
Save tbhaxor/fcde73f67faf251f2ea22a46a3a461d4 to your computer and use it in GitHub Desktop.
Simple TCP Client
from socket import socket, AF_INET, SOCK_STREAM
from sys import argv
argv.pop(0)
# instancing the client
client = socket(AF_INET, SOCK_STREAM)
# connecting to the server
try:
client.connect(("0.0.0.0", int(argv[0])))
except IndexError:
print("[!] Setting default port to 8090")
client.connect(("0.0.0.0", 8090))
while True:
# reading 4mB of chunk
data = client.recv(4096)
# end the loop if no data recieved
if not data.decode(): break
# printing on console
print(data.decode())
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment