Created
November 15, 2023 22:22
-
-
Save Lord-McSweeney/4cc2fd8aa606fb804538fb9bb18f3db9 to your computer and use it in GitHub Desktop.
sock
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 | |
import sys | |
kDefault_port = 18056 | |
def initiate_play(sock): | |
print("Initiating play!") | |
client_socket = socket() | |
try: | |
client_socket.connect((input("Connect to a server: "), kDefault_port)) | |
client_socket.sendall(b"HELO DRAWCLIENTv0.1") | |
recieved = client_socket.recv(128) | |
if recieved != b'WELCOME': | |
print("ERR Invalid server response!") | |
sys.exit() | |
except ConnectionRefusedError: | |
print("ERR Connection refused, please check server end") | |
sys.exit() | |
except OSError: | |
print("Operating system error, please check your network") | |
sys.exit() | |
initiate_play(client_socket) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment