PY
py
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
from time import time #, pickle
t = time()
# Designed to work with client.
# Only one server can use a port. Unknown if ephemeral ports should be used.
# Only the client reports if server.py is successfully contacted
import itertools, operator
from uuid import getnode
# identify physical server number
gn=getnode()
myMAC = ':'.join((itertools.starmap(operator.add, zip(*([iter("%012X" % gn)] * 2)))))
idx={'73':"ONE", '2B':"TWO", '2F':"THREE", '88':'FOUR'}[myMAC[-2:]]
print(idx)
# listen for client{}
import socket as s
_ = s.socket(s.AF_INET, s.SOCK_DGRAM)
_.connect(("10.255.255.255", 1)) # bogus; was 4.4.8.8 80
host = _.getsockname()[0] # localhost
port = 44444
server = s.socket(s.AF_INET, s.SOCK_STREAM)
server.settimeout(4.6)
server.bind((host, port))
server.listen(5) # connections, not timeout
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run