[jcifs] newbie problems and connection problem on unix box

Michael B Allen mba2000 at ioplex.com
Tue Jul 19 15:54:53 GMT 2005

On Tue, 19 Jul 2005 09:33:39 -0400
Mark Shifman <mark.shifman at yale.edu> wrote:

> >Linux ehh? Odd. Something's definately wrong there. Actually I think
> >there might be something about this in the FAQ.
> >  
> >
> Yes! Here it is.
>     * *Your hostname is resolving to* It is not uncommon on
>       Linux for an /etc/hosts file to map the hostname to such
>       as:
>      nano   localhost.localdomain    localhost
>       Taking the host name (e.g. nano) out of the localhost line should
>       solved the problem.
> This is a bit tedious though if you are testing on one linux box and 
> then running on another box. Also if you like using the short name for 
> your computer
> Since getLocalHost returns a short name for my computer, this might be a 
> reasonable solution
> jcifs.Config.setProperty( "jcifs.smb.client.laddr", 
> InetAddress.getLocalHost().getHostName()+"rest.of.domain");

First, the FAQ doesn't really explain why this problem happends. Personally I have a hostname in my /etc/hosts so there is obviously another factor involved. I suspect if the name is resolvable by DNS you might get different results. Why DNS should have anything to do with binding I don't know but there's not much I can do about it.

Anyway, I'll apply the below fix. That should pretty much eliminate the problem regardless.


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

More information about the jcifs mailing list