Donate Share

xmpp.py

Tracker: Feature Requests

5 IPv6 support - ID: 2851611
Last Update: Comment added ( noalwin )

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


Nobody/Anonymous ( nobody ) - 2009-09-04 18:50

5

Open

None

Nobody/Anonymous

None

None

Public


Comments ( 2 )




Date: 2009-12-18 13:21
Sender: noalwin

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


Date: 2009-12-18 13:16
Sender: noalwin

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')



Log in to comment.

Attached File ( 1 )

Filename Description Download
transports.py.patch Download

Change ( 1 )

Field Old Value Date By
File Added 341804: transports.py.patch 2009-09-04 18:50 nobody