Skip to content

Instantly share code, notes, and snippets.

@HavishNetla
Created July 21, 2019 17:17
Show Gist options
  • Save HavishNetla/a8f023e8fedfa1d3cb76e18940823a0e to your computer and use it in GitHub Desktop.
Save HavishNetla/a8f023e8fedfa1d3cb76e18940823a0e to your computer and use it in GitHub Desktop.
import socket
import time
from contextlib import closing
HOST = '192.168.1.171' # The server's hostname or IP address
PORT = 65432 # The port used by the server
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
print("conectiong")
print( s.connect_ex((HOST, PORT)))
print("sendong")
s.sendall(b'Hello world')
t0 = time.time()
counter = 0
while True:
try:
data = s.recv(1024)
print('Received', repr(data))
counter = counter + 1
except:
print(time.time() - t0)
print(counter)
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment