468,458 Members | 1,754 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,458 developers. It's quick & easy.

How to use SocketServer with IPv6

Hello,

I'm a Python newbie trying to figure out how to use SocketServer with
IPv6. I would like to set up a TCPServer working like below but how to
tell SocketServer I need to use AF_INET6?

import SocketServer
import logging as l

l.basicConfig(level=l.DEBUG,
format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S')
PORT = 5001

class CollectorHandler(SocketServer.BaseRequestHandler):

def setup(self):
l.info('%s connected!', self.client_address)
#self.request.send('hi ' + str(self.client_address) + '\n')

def handle(self):
data = self.request.recv(1024)
l.debug('Client sent this: %s\n', data)
def finish(self):
l.info('%s disconnected!', self.client_address)
#self.request.send('bye ' + str(self.client_address) + '\n')

if __name__=='__main__':
#server host is a tuple ('host', port)
#myserver = SocketServer.ThreadingTCPServer(('', 5001), CollectorHandler)
l.info('Collector software starting up, creating TCPServer.')
try:
myserver = SocketServer.TCPServer(('', PORT), CollectorHandler)
l.info('Listening to connections in port %d.', PORT)
myserver.serve_forever()
except KeyboardInterrupt:
pass

Thanks for any advice!

--
Tomi Hautakoski
Feb 12 '07 #1
0 1181

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Agent | last post: by
3 posts views Thread by Olivier Hoarau | last post: by
3 posts views Thread by Ergin Aytac | last post: by
reply views Thread by Adil Hasan | last post: by
5 posts views Thread by missiplicity | last post: by
3 posts views Thread by jiri.juranek | last post: by
3 posts views Thread by Pramod TK | last post: by
8 posts views Thread by Giampaolo Rodola' | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.