Writing a Jabber client that uses Twisted Words. I would like to know an IP address and hostname of remote peer. xmlstream.transport.getPeer().host return hostname, while it should return IP address (xmlstream is an instance of twisted.words.protocols.jabber.xmlstream.XmlStream).
Update: Yes, my Twisted is rather outdated, from Ubuntu Hardy package:
$ python -c "import twisted; print twisted.__version__"
2.5.0
You’ve run into a bug fixed 3 years ago, in Twisted 8.2.0. You should upgrade to a more recent version of Twisted. (I would suggest the recently-announced prerelease of Twisted 11.0; now’s a good time to test!) If you’ve found this bug in a more recent version of Twisted, you should reopen that bug, and explain how to reproduce it!
If you need to support whatever older version of Twisted you’re using, rather than
socket, which is an accidentally-exposed implementation detail of yourITransportimplementation, you should usegetHandle, which is at least the documented, public way to get at this implementation-dependent stuff, like this:Note that this will not work on some reactors, notably the IOCP reactor, which uses something other than BSD sockets for its network communication.
(Jean-Paul already noted most of this in a comment, but I felt this should show up as an answer.)