471,075 Members | 859 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,075 software developers and data experts.

How to use SocketServer with IPv6


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

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.')
myserver = SocketServer.TCPServer(('', PORT), CollectorHandler)
l.info('Listening to connections in port %d.', PORT)
except KeyboardInterrupt:

Thanks for any advice!

Tomi Hautakoski
Feb 12 '07 #1
0 1321

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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.