Menu

#9 IPv6 support

open
nobody
None
5
2009-09-04
2009-09-04
Anonymous
No

There will be nice, if xmpp library will support IPv6. Quick-and-dirty implementation attached.

Discussion

  • Nobody/Anonymous

     
  • NoAlWin

    NoAlWin - 2009-12-18

    It doesn't work for me, you seem to forgot the socket creation

    I made an alternative implementation based on the python documentation

    Sorry but I can't see the option to add a new file, so I paste it here

    --- old/transports.py 2009-12-18 14:11:46.941708255 +0100
    +++ new/transports.py 2009-12-18 14:11:53.594624762 +0100
    @@ -122,8 +122,30 @@
    """ Try to connect. Returns non-empty string on success. """
    try:
    if not server: server=self._server
    - self._sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    - self._sock.connect((server[0], int(server[1])))
    +
    + # Since python2.6 we can do
    + #self._sock=socket.create_connection((server[0], int(server[1])))
    + # But for compatibility with previous versions
    + s = None
    + for res in socket.getaddrinfo(server[0], int(server[1]), socket.AF_UNSPEC, socket.SOCK_STREAM):
    + af, socktype, proto, canonname, sa = res
    + try:
    + s = socket.socket(af, socktype, proto)
    + except socket.error, msg:
    + s = None
    + continue
    + try:
    + s.connect(sa)
    + except socket.error, msg:
    + s.close()
    + s = None
    + continue
    + break
    + if s is None:
    + raise socket.error, msg
    +
    + self._sock=s
    +
    self._send=self._sock.sendall
    self._recv=self._sock.recv
    self.DEBUG("Successfully connected to remote host %s"%`server`,'start')

     
  • NoAlWin

    NoAlWin - 2009-12-18

    Hmmm it seems that pasting here code it's a bad idea, here it should be readable http://pastebin.com/f5ec9911

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.