效果一样吧。
没有过第二种。
不过你要设定timeout,那就用第二种嘛。

解决方案 »

  1.   

    在jbuider的帮助文档里的解释是:
    1.Creates a stream socket and connects it to the specified port number on the named host
    2.(关于connect函数的)Connects this socket to the server with a specified timeout value
    因为第二种的解释里没有说明是stream socket,所有我担心它不能发送和接收信息。
      

  2.   

    前一种可以用socket.setSoTimeout(时间)来!来等效后一种