import socket import re server socket socket server bind localhost 909

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import socket
import re
server = socket.socket()
server.bind(('localhost', 9090))
server.listen(5)
serv, addr = server.accept()
while 1:
cmd = serv.recv(1024)
serv.send('+')
string = serv.recv(1024)
if cmd == 'e':
a = re.findall('[\w\d]+@[\w\d]+[.]ru|[\w\d]+@[\w\d]+[.]com', string)
serv.send(" ".join(a))
elif cmd == 'c':
a = re.findall('[A-Z]\w*', string)
serv.send(" ".join(a))