是不是应该new Socket(不带参数)
然后connect(SocketAddress remoteAddr, int timeout)
这里面有个timeout参数。

解决方案 »

  1.   

    public Socket (String dstName, int dstPort)Since: API Level 1
    Creates a new streaming socket connected to the target host specified by the parameters dstName and dstPort. The socket is bound to any available port on the local host.
    Implementation note: this implementation tries each IP address for the given hostname until it either connects successfully or it exhausts the set. It will try both IPv4 and IPv6 addresses in the order specified by the system property "java.net.preferIPv6Addresses".注意Implementation note里面的内容,这正是你的慢的原因,可以肯定了。
      

  2.   

    恩,非常感谢,Implementation note中的exhausts the set,这个set是什么set?
    另外哪里查java的api啊?
      

  3.   

    就是你的所有可能可用的适配器,比如你有两块网卡,还有一些虚拟连接什么的,都会尝试一下。
    甚至同一地址,所有的端口(自己使用的端口,远程端的端口不会,只会连接你指定的那个)都会试一下,这一点我也不确定。http://developer.android.com/reference/java/net/Socket.html