Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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()