-
Notifications
You must be signed in to change notification settings - Fork 0
/
HOMEWORK3.txt
55 lines (39 loc) · 1.74 KB
/
HOMEWORK3.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Commit homework #2 to a 'homework' repo on github.com. Something like:
git://github.com/cbnoonan/homework.git/2/cogserver.py.
Given homework #2, copy it to a different location in the repo (like
3/cogserver2.py) and add the following features to it, via the
optparse module.
o Accept an optional host and port arguments. -o HOST (or --host=HOST)
and -p PORT (or --port=PORT). These default to Homework #2's values if
not defined.
o Accept an optional command line argument -e ENCODING (or
--encoding=ENCODING). When defined, makes the server encode the
accepted data from the client (the data printed to stdout) with that
encoder.
Output should be as follows:
$ python cogserver2.py --help
usage: cogserver2.py [options]
options:
-h, --help show this help message and exit
-o HOST, --host=HOST the host to bind/connect to
-p PORT, --port=PORT the port to bind/connect to
-e ENCODING, --encoding=ENCODING
server's output encoding
$ python cogserver2.py -o localhost -p 9500
CogServer (thread: Thread-1): ready to serve on port: 9500
cog_client (thread: MainThread): connecting to port: 9500
Welcome to CogServer ('127.0.0.1', 50791)
fhc qbtubhfr...
JUNG!
$ python cogserver2.py -e string_escape
CogServer (thread: Thread-1): ready to serve on port: 8005
cog_client (thread: MainThread): connecting to port: 8005
Welcome to CogServer ('127.0.0.1', 50802)
fhc qbtubhfr...\r\n\r\n\tJUNG!
$ python cogserver2.py -p 9600 -e hex
CogServer (thread: Thread-1): ready to serve on port: 9600
cog_client (thread: MainThread): connecting to port: 9600
Welcome to CogServer ('127.0.0.1', 50808)
6668632071627475626866722e2e2e0d0a0d0a094a554e4721
Push your changes to github as often as possible so I can see your
progress.