1. 链接到服务器
Socket(String host,int port)创建一个套接字,用来链接给定的主机和端口
package java.net;
public class Socket implements java.io.Closeable {
public Socket(String host, int port) throws UnknownHostException, IOException
{
this(host != null ? new InetSocketAddress(host, port) :
new InetSocketAddress(InetAddress.getByName(null), port),
(SocketAddress) null, true);
}
……
}