Skip to content

Commit d95ca2b

Browse files
committed
remove answers from master branch for session 01
1 parent 8afeccc commit d95ca2b

File tree

3 files changed

+1
-98
lines changed

3 files changed

+1
-98
lines changed

resources/session01/echo_client.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

resources/session01/echo_server.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

resources/session01/session1.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
import socket
22

3-
4-
def get_named_services(first_port=0, last_port=2**15+2**14):
5-
tmpl = '{0: >4}: {1}'
6-
for i in xrange(first_port, last_port):
7-
try:
8-
service = socket.getservbyport(i)
9-
except socket.error:
10-
continue
11-
print tmpl.format(i, service)
12-
13-
143
def get_constants(prefix):
154
return dict(
165
(getattr(socket, n), n)
@@ -21,10 +10,7 @@ def get_constants(prefix):
2110
# this example is more 'pythonic' for 2.7 and above (where dictionary
2211
# comprehensions exist)
2312
def get_constants_27(prefix):
24-
return {
25-
getattr(socket, n):n for n in dir(socket)
26-
if n.startswith(prefix)
27-
}
13+
return {getattr(socket, n):n for n in dir(socket) if n.startswith(prefix)}
2814

2915

3016
def get_address_info(host, port):
@@ -39,13 +25,3 @@ def get_address_info(host, port):
3925
print 'canonical name: ', nam
4026
print 'socket address: ', add
4127
print
42-
43-
44-
def print_address_constants():
45-
addrs = get_constants('INADDR')
46-
for val, name in addrs.items():
47-
hexval = hex(val)
48-
packed = socket.inet_aton(hexval)
49-
addr = socket.inet_ntoa(packed)
50-
tmpl = '{0: >24}: {1: <10} {2: <16}'
51-
print tmpl.format(name, hexval, addr)

0 commit comments

Comments
 (0)