By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,918 Members | 2,248 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

How to use SocketServer with IPv6

P: n/a

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

Thanks for any advice!

Tomi Hautakoski
Feb 12 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.