Skip to content
Snippets Groups Projects
Commit 2c9b50e1 authored by Doug Harms's avatar Doug Harms
Browse files

Changed command line arguments

parent ffa18263
No related merge requests found
......@@ -5,7 +5,15 @@ import sys
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Connect the socket to the port where the server is listening
server_address = ('localhost', 10000)
# process command line arguments
argc = len(sys.argv)
if argc != 3:
print ("usage: python3 client.py serverAddress serverPort")
sys.exit()
serverName = sys.argv[1]
port = int(sys.argv[2])
server_address = (serverName,port)
print ('connecting to {} port {}'.format(server_address[0], server_address[1]) )
sock.connect(server_address)
......
......@@ -4,8 +4,15 @@ import sys
# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# process command line arguments
argc = len(sys.argv)
if argc != 2:
print ("usage: python3 server.py serverPort")
sys.exit()
port = int(sys.argv[1])
# Bind the socket to the port
server_address = ('localhost', 10000)
server_address = ('',port)
print ('starting up on {} port {}'.format(server_address[0], server_address[1]))
sock.bind(server_address)
......@@ -19,7 +26,7 @@ while True:
connection, client_address = sock.accept()
print ('connection from {}'.format(client_address))
# Receive the data in small chunks and retransmit it. Continue doing this
# until the client closes the tcp connection
while True:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment