Issue2078
Created on 2013-08-26.15:50:22 by irmen, last changed 2014-06-25.16:04:09 by zyasoft.
File name |
Uploaded |
Description |
Edit |
Remove |
issue2078.patch
|
santa4nt,
2014-05-22.00:37:35
|
AF_INET6 socket address should be formed in 4-tuple. |
|
|
issue2078.patch
|
santa4nt,
2014-05-22.01:14:17
|
Force Inet4Address when dealing if "any" (local) address. |
|
|
msg8090 (view) |
Author: Irmen de Jong (irmen) |
Date: 2013-08-26.15:50:22 |
|
When creating an ipv4 socket and binding it on ipaddr_any, getsockname returns an ipv6 address:
>>> s=socket(AF_INET, SOCK_STREAM)
>>> s.bind(("",0))
>>> s.listen(1)
>>> s.getsockname()
(u'0:0:0:0:0:0:0:0', 58526)
Expected behavior: return the ipv4 address "0.0.0.0" instead.
|
msg8105 (view) |
Author: Alan Kennedy (amak) |
Date: 2013-09-07.13:34:06 |
|
Hi Irmen.
I am not able to reproduce this on my local setup.
What version of jython is this happening on?
What java version?
What operating system?
|
msg8109 (view) |
Author: Irmen de Jong (irmen) |
Date: 2013-09-08.13:30:52 |
|
Happens with jython trunk (2.7b1+).
Happens on Windows 7 (java 1.7) and OS X 10.8.4 (java 1.6).
Both machines have a functional IPV6 (and IPV4) network address assigned.
|
msg8472 (view) |
Author: Jim Baker (zyasoft) |
Date: 2014-05-21.20:55:21 |
|
Same result with the new socket-reboot code in beta 3, but this is not surprising since this part is unchanged (the internal function _socket._get_jsockaddr)
Target beta 4
|
msg8479 (view) |
Author: Jim Baker (zyasoft) |
Date: 2014-05-21.21:29:10 |
|
Also need to fix the nearly identical issue (from an implementation perspective) as reported in #2079:
from socket import *
s=socket(AF_INET6, SOCK_STREAM)
s.bind(("",0,0,0))
s.listen(1)
assert len(s.getsockname()) == 4
|
msg8521 (view) |
Author: Santoso Wijaya (santa4nt) |
Date: 2014-05-22.00:35:58 |
|
Netty4 is strange... you can bind its ServerBootstrap with an Inet4Address, but when you query the Channel it returns for its local address, you get an Inet6Address!
Here's a print-peppered _realsocket.listen() method:
def listen(self, backlog):
# ...
print 'Binding to {:s} with type {:s}'.format(repr(self.bind_addr.getAddress()), type(self.bind_addr.getAddress()))
future = b.bind(self.bind_addr.getAddress(), self.bind_addr.getPort())
# ...
self.channel = future.channel()
localaddr = self.channel.localAddress()
print 'The channel is bound to {:s} with type {:s}'.format(repr(localaddr.getAddress()), type(localaddr.getAddress()))
# ...
And what you get when you execute that modified method:
Binding to /0.0.0.0 with type <type 'java.net.Inet4Address'>
The channel is bound to /0:0:0:0:0:0:0:0 with type <type 'java.net.Inet6Address'>
And that's why you get an IPv6 '0' address from getsockname() after binding it with IPv4 '0' address.
|
msg8522 (view) |
Author: Santoso Wijaya (santa4nt) |
Date: 2014-05-22.00:37:34 |
|
As for @zyasoft test case outputting the correct number of tuple elements for AF_INET6 socket address, here's a simple patch to address just that.
The original issue still remains since I don't know how to work around that Netty 4 quirk yet.
|
msg8535 (view) |
Author: Santoso Wijaya (santa4nt) |
Date: 2014-05-22.01:14:17 |
|
How about this hack-ish workaround?
|
msg8677 (view) |
Author: Santoso Wijaya (santa4nt) |
Date: 2014-06-18.18:25:17 |
|
Merged in this commit: https://bitbucket.org/jython/jython/commits/0e62bf96c77388f61ac68c22482f3c2ab9e329a4
|
|
Date |
User |
Action |
Args |
2014-06-25 16:04:09 | zyasoft | set | status: pending -> closed |
2014-06-18 19:28:01 | zyasoft | set | status: open -> pending resolution: accepted -> fixed |
2014-06-18 18:25:17 | santa4nt | set | messages:
+ msg8677 |
2014-05-22 01:14:17 | santa4nt | set | files:
+ issue2078.patch messages:
+ msg8535 |
2014-05-22 00:37:35 | santa4nt | set | files:
+ issue2078.patch keywords:
+ patch messages:
+ msg8522 |
2014-05-22 00:35:59 | santa4nt | set | messages:
+ msg8521 |
2014-05-21 22:51:23 | santa4nt | set | type: behaviour |
2014-05-21 22:51:19 | santa4nt | set | nosy:
+ santa4nt |
2014-05-21 21:30:01 | zyasoft | set | title: socket.getsockname() returns ipv6 name for ipv4 family when binding on ipaddr_any -> socket.getsockname() should return correct addresses when binding on ipaddr_any |
2014-05-21 21:29:10 | zyasoft | set | messages:
+ msg8479 |
2014-05-21 20:55:21 | zyasoft | set | assignee: amak -> zyasoft resolution: accepted messages:
+ msg8472 nosy:
+ zyasoft |
2013-09-08 13:30:52 | irmen | set | messages:
+ msg8109 |
2013-09-07 13:34:07 | amak | set | assignee: amak messages:
+ msg8105 nosy:
+ amak |
2013-08-26 16:01:06 | irmen | set | components:
+ Core versions:
+ Jython 2.7 |
2013-08-26 15:50:22 | irmen | create | |
|