Issue1169499
Created on 2005-03-23.22:44:35 by toddcarper, last changed 2007-05-18.21:03:58 by amak.
| Messages | |||
|---|---|---|---|
| msg968 (view) | Author: Todd Carper (toddcarper) | Date: 2005-03-23.22:44:35 | |
It appears that calling bind to specify the ip address and
port on which to bind locally stores the settings but
does not provide them to connect.
In this case, connect always binds to the primary ip
address of the machine.
existing code - self.addr, from bind, is not referenced
def connect(self, addr, port=None):
"This signifies a client socket"
if port is not None:
addr = (addr, port)
assert not self.sock
host, port = addr
if host == "":
host = java.net.InetAddress.getLocalHost()
self._setup(java.net.Socket(host, port))
modified code
def connect(self, addr, port=None):
"This signifies a client socket"
if port is not None:
addr = (addr, port)
assert not self.sock
host, port = addr
if host == "":
host = java.net.InetAddress.getLocalHost()
if self.__dict__.has_key("addr"):
caddr, cport = self.addr
self._setup(java.net.Socket(host, port,
java.net.InetAddress.getByName(caddr), cport))
else:
self._setup(java.net.Socket(host, port))
There may be a better way to implement the change,
but by providing the optional 2 parameters, it is possible
to bind to the desired ip address and port.
Without the change, applications will generally work,
but the primary ip address will always be utilized.
Howerver, applications which require usage of a specific
IP will not function as desired.
|
|||
| msg969 (view) | Author: Alan Kennedy (amak) | Date: 2007-05-18.21:03:58 | |
This was indeed a bug: it should be possible to bind a client socket to a local address. The old code ignored this fact. I have checked a fix into the new socket module, which is currently in the sandbox but will hopefully be included in the distribution soon. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2005-03-23 22:44:35 | toddcarper | create | |
Supported by Python Software Foundation,
Powered by Roundup