Created
November 30, 2019 08:26
-
-
Save tbhaxor/fcde73f67faf251f2ea22a46a3a461d4 to your computer and use it in GitHub Desktop.
Simple TCP Client
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
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