diff --git a/client.py b/client.py new file mode 100644 index 0000000..9d55451 --- /dev/null +++ b/client.py @@ -0,0 +1,11 @@ +import socket + +HOST = "127.0.0.1" # The server's hostname or IP address +PORT = 65432 # The port used by the server + +with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.connect((HOST, PORT)) + s.sendall(b"Hello, world") + data = s.recv(1024) + +print(f"Received {data!r}") diff --git a/main.py b/main.py index 30ecd1a..f76c5d2 100644 --- a/main.py +++ b/main.py @@ -82,12 +82,8 @@ def checkWin(board, player): if all(board[col + i][row - i] == player for i in range(winCount)): return [(col + i, row - i) for i in range(winCount)] -# Board will be 7x6. - -# O = open, R = red, Y = yellow -# because this is defined like this, you could technically save a game then load from where you left off - # This is defined as columns, not rows. So tile 0 on column 0 is the bottom left tile of the board +# you index like board[column][row] board = [ ['O', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', 'O'], diff --git a/server.py b/server.py new file mode 100644 index 0000000..f702a37 --- /dev/null +++ b/server.py @@ -0,0 +1,16 @@ +import socket + +HOST = "0.0.0.0" +PORT = 65432 + +with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.bind((HOST, PORT)) + s.listen() + conn, addr = s.accept() + with conn: + print(f"Connected by {addr}") + while True: + data = conn.recv(1024) + if not data: + break + conn.sendall(data) \ No newline at end of file