Fix the client to work regardless of the IP/Port combination, default to localhost and 8181 if nothing is provided.
This commit is contained in:
parent
12eb4fb3f5
commit
fad9f50ff8
1 changed files with 10 additions and 2 deletions
|
|
@ -2,11 +2,19 @@ import socket
|
|||
import sys
|
||||
import select
|
||||
|
||||
SERVER_HOST = 'localhost'
|
||||
SERVER_PORT = 8181
|
||||
BUFFER_SIZE = 1024
|
||||
DEFAULT_HOST = 'localhost'
|
||||
DEFAULT_PORT = 8181
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
SERVER_HOST = input(f"Enter server host (default: {DEFAULT_HOST}): ") or DEFAULT_HOST
|
||||
SERVER_PORT = input(f"Enter server port (default: {DEFAULT_PORT}): ") or DEFAULT_PORT
|
||||
SERVER_PORT = int(SERVER_PORT)
|
||||
else:
|
||||
SERVER_HOST = sys.argv[1]
|
||||
SERVER_PORT = int(sys.argv[2])
|
||||
|
||||
# create a socket object
|
||||
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue