No subject


Thu Mar 18 17:34:04 MDT 2010


> Ok, this looks like something worth fixing. I think using the 1.4
> timeout looks like the right track but I haven't really looked at the
> problem so I don't know. Aslo, unfortunately this is the sort of thing
> that could take a really long time to make it into the code since I
> don't really work on JCIFS for free or Free anymore. But I've added
> this to the TODO.
>
> Thanks for the report.
>
> Mike

The fix, 9 months later.
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0InetAddress addr =3D
InetAddress.getByName(address.getHostAddress());
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(!addr.isReachable(SO_TIMEOUT)) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new IOException("host unreachable");
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}

and if you want to be thorough.

=A0 =A0 =A0 =A0 =A0 =A0if (port =3D=3D 139) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ssn139();
=A0 =A0 =A0 =A0 =A0 =A0} else {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (port =3D=3D 0) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0port =3D DEFAULT_PORT; // 445
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0InetAddress addr =3D
InetAddress.getByName(address.getHostAddress()); //fix
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(!addr.isReachable(SO_TIMEOUT)) {
=A0 =A0 =A0 =A0 =A0 =A0 //fix
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new IOException("host unreachable");
=A0 =A0 =A0 =A0 =A0//fix
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
=A0 =A0 =A0 =A0 =A0 =A0 //fix

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (localAddr =3D=3D null) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0InetSocketAddress remoteAddr =3D new
InetSocketAddress(addr, port);//fix
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0socket =3D new Socket();
 =A0 =A0 =A0 =A0 =A0 =A0 //fix
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0socket.connect(remoteAddr, SO_TIMEOU=
T);
=A0 =A0 =A0 =A0 =A0 =A0 =A0//fix
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0socket =3D new Socket();
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0//fix
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0InetSocketAddress remoteAddr =3D new
InetSocketAddress(addr, port); =A0 =A0 =A0 //fix
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0InetSocketAddress localAdd =3D new
InetSocketAddress(localAddr,localPort);//fix
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0socket.bind(localAdd);
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0//fix
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0socket.connect(remoteAddr,SO_TIMEOUT=
);
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0//fix
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0socket.setSoTimeout( SO_TIMEOUT );
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0out =3D socket.getOutputStream();
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0in =3D socket.getInputStream();
=A0 =A0 =A0 =A0 =A0 =A0}

--
dlm


More information about the jCIFS mailing list