[jcifs] Cannot assign requested address

Michael B Allen mba2000 at ioplex.com
Thu Aug 11 06:20:11 GMT 2005


On Wed, 10 Aug 2005 17:39:06 +0200
Mathias Dietz <MDIETZ at de.ibm.com> wrote:

> with jcifs 1.2.1 I get the following error message when I try to connect to
> a samba share. (using fedora core 4 and java 1.5)
> jcifs.util.transport.TransportException
> java.net.SocketException: Invalid argument or cannot assign requested
> address
>       at java.net.PlainSocketImpl.socketConnect(Native Method)
>       ......
>       at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:228)
>       at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:266)
>       at jcifs.util.transport.Transport.run(Transport.java:204)
>       at java.lang.Thread.run(Thread.java:568)
> 
> After some testing and debugging I found that the problem does not occur
> with jcifs 1.1.11.
> With jcifs 1.2.1 the config class has been changed to the following:
> 
>     public static InetAddress getLocalHost() {
>         String addr = prp.getProperty( "jcifs.smb.client.laddr" );
>         try {
>             if( addr == null ) {
>   --->>>            return InetAddress.getLocalHost();     <<<----
>             }
>             return InetAddress.getByName( addr );
>         } catch( UnknownHostException uhe ) {
>             if( log.level > 0 ) {
>                 log.println( addr );
>                 uhe.printStackTrace( log );
>         }   }
>         return null;
>     }
> 
> If no jcifs.smb.client.laddr is specified, then localhost/127.0.0.1 is
> returned and
> SMBTransport uses the returned value to create a socket.
>  ->>  socket = new Socket( address.getHostAddress(), port, localAddr,
> localPort );
> 
> This is not possible because the samba server is not reachable via
> 127.0.0.1 (NoRouteToHost!).
> 
> Could someone fix this bug ? Possible solutions:
>       A) change the Config.getLocalHost() method to return null if no
> jcifs.smb.client.laddr is specified
>       B) change SMBTransport and replace LADDR with Config.getInetAddress(
> "jcifs.smb.client.laddr", null )  (jcifs 1.1.11 like)

Nice analysis. This bug is on The List but I had not really looked at
it closely yet. I think your diagnosis will be helpful. If 1.1.11 really
used option B then I think that is the way to go.

Note that on systems integrated into a domain environment this bug will
not be tripped up because getLocalHost will return the real IP. It's
only when your hostname doesn't resolve to an IP via DNS that the machine
falls back to 127.0.0.1.

> Question: Where is the most current JCIFS version ? Does a CVS or SVN
> repository exist ?

In the download area. No.

Mike


More information about the jcifs mailing list