[jcifs] newbie problems

Michael B Allen mba2000 at ioplex.com
Mon Jul 18 15:21:07 GMT 2005


On Mon, 18 Jul 2005 09:48:26 -0400
Mark Shifman <mark.shifman at yale.edu> wrote:
> >Add some System.out.printlns to SmbTransport.java:228 to print all of the arguments passed to the Socket constructor. 
> >  
>         System.out.println("address " +  address.getHostAddress() + " 
> port " + port + " localAddr " + localAddr+" local port " + localPort);
>                 socket = new Socket( address.getHostAddress(), port, 
> localAddr, localPort );
> ...
> outputs:
> address 172.23.78.119 port 445 localAddr moussaka/127.0.0.1 local port 0
> 
> So the constructor doesn't like what it is given as localAddr.   If I 
> put my real ip adress in ,  the socket is created. 
> Either I have my machine configured strangely (it seems to work with 
> everything else) or jcifs is picking up my local address incorrectly
> or (the most likely) I don't really understand what is going on.
> mas

You don't have a loopback adapter. I've seen this before on
Windows machines. Either you need to setup loopback or use the
jcifs.smb.client.laddr property to set the address of the interface
to use.

We could put a clause in the code like:

  if (localAddr == InetAddress.getLocalHost()) {
      socket = new Socket( address.getHostAddress(), port );
  } else {
      socket = new Socket( address.getHostAddress(), port, localAddr, localPort );
  }

If you leave out the localAddr and localPort properties alltogether does
it work ok?

Mike


More information about the jcifs mailing list