Message6407

Author amak
Recipients amak, xjyvb3
Date 2011-02-26.20:35:10
SpamBayes Score 5.6242156e-06
Marked as misclassified No
Message-id <1298752510.9.0.612375540451.issue1711@psf.upfronthosting.co.za>
In-reply-to
Content
First off, as mentioned in a previous message, the _use_ipv4_addresses_only(False) only affects return values from the getaddrinfo() function.

Therefore, if you want to use IPV6 addresses, the best code would look like this.

>>> import socket
>>> socket._use_ipv4_addresses_only(False) # Not necessary, this is the default
>>> address = socket.getaddrinfo("localhost", 9999, socket.AF_INET6)[0][4]
>>> address
('0:0:0:0:0:0:0:1', 9999, 0, 0)
>>> sock=socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
>>> sock.connect(address)

The address actually being used in your code sample, i.e. what is used internally by the conect() call, can be illustrated as follows

>>> import socket
>>> address = socket._get_jsockaddr( ("::1", 9999) )
>>> type(address)
<type 'java.net.InetSocketAddress'>
>>> address
/0:0:0:0:0:0:0:1:9999
>>> sock=socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
>>> sock.connect(address)
History
Date User Action Args
2011-02-26 20:35:10amaksetmessageid: <1298752510.9.0.612375540451.issue1711@psf.upfronthosting.co.za>
2011-02-26 20:35:10amaksetrecipients: + amak, xjyvb3
2011-02-26 20:35:10amaklinkissue1711 messages
2011-02-26 20:35:10amakcreate