Skip to content

Instantly share code, notes, and snippets.

@studiawan
Last active March 22, 2021 00:32
Show Gist options
  • Save studiawan/6930700 to your computer and use it in GitHub Desktop.
Save studiawan/6930700 to your computer and use it in GitHub Desktop.
Client used to access server-select.py
import socket
import sys
server_address = ('192.168.0.32', 5000)
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(server_address)
sys.stdout.write('>> ')
try:
while True:
message = sys.stdin.readline()
client_socket.send(bytes(message, 'utf-8'))
received_data = client_socket.recv(1024).decode('utf-8')
sys.stdout.write(received_data)
sys.stdout.write('>> ')
except KeyboardInterrupt:
client_socket.close()
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment