Message968

Author toddcarper
Recipients
Date 2005-03-23.22:44:35
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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.
History
Date User Action Args
2008-02-20 17:17:21adminlinkissue1169499 messages
2008-02-20 17:17:21admincreate