> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> 
> Incidentally, it doesn't actually hang indefinately, for me it looks like it
> times out after about 3 minutes and 12 seconds.  
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> 
> Well, since the con.open() method creates a new Socket object, it is subject
> to the behavior of the Socket class.  Unfortunately, at least as of 1.3,
> attempting to create a new Socket to a host/port combo that does not answer
> blocks indefinately (or at least for a very long time), this can't be
> avoided directly.  (It would be really nice if the JDK provided a Socket
> constructor that took a timeout value to pass to the underlying OS).
> 
        Actually I must confess, I'm sort of trolling. I'm the author of jCIFS
        (the SMB client) and I wanted to know how you addressed this problem. I did
        not know eventually a Connection timed out exception is thrown. This is good
        news. I have done a bit of research elsewhere and found out 1.4 does indeed
        have a timeout parameter for the Socket constructor. Unfortunately that doesn't
        help me because jCIFS still supports 1.1 and it would be a shame to break that.

>   The
> three ways I can think of to avoid it off hand are:
> 
>       1. Implement a timeout mechanism outside of HttpClient with a
> seperate thread that interrupts the connection attempts.
> 
        Tried and failed. If you look up my ([EMAIL PROTECTED]) recent post to
        comp.lang.java.programmer you'll see I tested this by trying to interrupt() the
        Socket() calling Thread. The results depend on which jre you're using but both
        end up sticking in Socket() in an interrupted state.

>       2. Implement a Socket object in the HttpClient framework that uses
> this same sort of mechanism but hides the details behind the API
> 
        With JNI?

>       3. Use the 1.4 JDK and upgrade everything to use the new channels
> API in non-blocking mode.
> 
        JDK 1.4 has a timeout parameter for Socket().

        Thanks,
        Mike
        http://jcifs.samba.org/


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to