Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   problem with ThreadingTCPServer Handler (http://www.velocityreviews.com/forums/t953775-problem-with-threadingtcpserver-handler.html)

jorge 10-23-2012 02:36 PM

problem with ThreadingTCPServer Handler
 
I'm programming a server that most send a message to each client
connected to it and nothing else. this is obviously a base of what i
want to do. the thing is, I made a class wich contains the Handler class
for the ThreadingTCPServer and starts the server but i don't know how
can i access the message variable contained in the class from the
Handler since I have not to instance the Handler by myself.
here is the base code of what I'm doing.

import SocketServer
import socket
from threading import Thread

class CustomTCPServer:
msg = "no message"
outport = 8080

class Handler(SocketServer.BaseRequestHandler):
def handle(self):
self.request.sendall('<here goes msg from CustomTCPServer>')


def __init__(self,msg,outport):
self.msg = server
self.outport = outport

def runServer(self):
addr = ('',self.outport)
s = SocketServer.ThreadingTCPServer(addr,self.Handler)
r = Thread(target=s.serve_forever).start()
print '> Server running running',self.server,self.outport


CustomTCPServer('msg1',1212).runServer()
CustomTCPServer('msg2',1213).runServer()

can anyone please help me?

10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS...
CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION

http://www.uci.cu
http://www.facebook.com/universidad.uci
http://www.flickr.com/photos/universidad_uci

Miki Tebeka 10-23-2012 08:51 PM

Re: problem with ThreadingTCPServer Handler
 
According to the docs (http://docs.python.org/library/socke...andler-objects) there's self.server available.

Miki Tebeka 10-23-2012 08:51 PM

Re: problem with ThreadingTCPServer Handler
 
According to the docs (http://docs.python.org/library/socke...andler-objects) there's self.server available.


All times are GMT. The time now is 10:05 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57