-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathServer.py
More file actions
40 lines (28 loc) · 830 Bytes
/
Server.py
File metadata and controls
40 lines (28 loc) · 830 Bytes
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
# coding=utf-8
import pickle
import socket
import threading
#vamos a conservar una lista de números.
someList = [1,2,7,9,0]
pickledList = pickle.dumps(someList)
#Nustra Clase hilo
class ClientThread ( threading.Thread ):
def __init__(self, channel, details):
self.channel = channel
self.details = details
threading.Thread.__init__(self)
def run(self):
print'Received connection :', self.details[0]
self.channel.send (pickledList)
for x in xrange(10):
print self.channel.recv(1024)
self.channel.close()
print 'Closed connection', self.details[0]
# set up the server:
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('',2727))
server.listen(5)
#Have the server serve "Forever":
while True:
channel, details = server.accept()
ClientThread ( channel, details ).start()