Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HavishNetla/6bc10c75101637c6a45a1ac6c7580226 to your computer and use it in GitHub Desktop.
Save HavishNetla/6bc10c75101637c6a45a1ac6c7580226 to your computer and use it in GitHub Desktop.
import socket
from contextlib import closing
HOST = '127.0.0.1' # 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:
s.connect((HOST, PORT))
s.sendall(b'Hello, world')
data = s.recv(1024)
print('Received', repr(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment