论坛首页 入门技术论坛

(请教)java中socket 默认超时时间是?

浏览 17507 次
该帖已经被评为新手帖
作者 正文
   发表时间:2007-03-07  

java中socket 默认超时时间是多久?
是50秒吗?
   发表时间:2007-03-09  
晕,从JAVA转到新手版,怎么还是没有人告诉我呢?
这是我前天在一家公司的面试题,我当时回答的是60秒。
但是google和百度都还找不到答案,唯一有个地方说50秒。
这是属于TCP/IP里面的东西吗?
0 请登录后投票
   发表时间:2007-03-09  
MS:永远吧
connect

public void connect(SocketAddress endpoint,
                    int timeout)
             throws IOException

    Connects this socket to the server with a specified timeout value. 
    A timeout of zero is interpreted as an infinite timeout.
    The connection will then block until established or an error occurs.

    Parameters:
        endpoint - the SocketAddress
        timeout - the timeout value to be used in milliseconds. 
    Throws:
        IOException - if an error occurs during the connection 
        SocketTimeoutException - if timeout expires before connecting 
        IllegalBlockingModeException - 
        if this socket has an associated channel, and the channel is in non-blocking mode 
        IllegalArgumentException - 
        if endpoint is null or is a SocketAddress subclass not supported by this socket
    Since:
        1.4




选自java API :java.net.Socket
0 请登录后投票
   发表时间:2007-03-09  
嗯,超时时间是可以设置的,但是缺省的超时时间是多少呢?
0 请登录后投票
   发表时间:2007-04-25  
A timeout of zero is interpreted as an infinite timeout.

不是写了么,这就是缺省。
0 请登录后投票
   发表时间:2007-04-25  
cnhawkwing 写道
晕,从JAVA转到新手版,怎么还是没有人告诉我呢?
这是我前天在一家公司的面试题,我当时回答的是60秒。
但是google和百度都还找不到答案,唯一有个地方说50秒。
这是属于TCP/IP里面的东西吗?


呵呵,我感觉这里说理论的比较多,真的碰到点问题,javaeye未必是最好的选择。
0 请登录后投票
   发表时间:2007-05-29  
getSoTimeout()
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics