我刚刚学会使用socket进行本机的TCP/IP的访问,但是,我想尝试着连接yahoo.com.cn等网站,对其端口问题几乎不了解,
public class SimpleClient{
public static void main(String[] args) throws IOException{
int c;
Socket s1;
InputStream s1In;
DataInputStream dis; s1 = new Socket("yahoo.com.cn",25); s1In = s1.getInputStream();
dis = new DataInputStream(s1In); String st = new String(dis.readUTF());
System.out.println(st); s1In.close();
s1.close();
}
}
我想尝试打开yahoo.com.cn的主页,应该怎么做呢?
public class SimpleClient{
public static void main(String[] args) throws IOException{
int c;
Socket s1;
InputStream s1In;
DataInputStream dis; s1 = new Socket("yahoo.com.cn",25); s1In = s1.getInputStream();
dis = new DataInputStream(s1In); String st = new String(dis.readUTF());
System.out.println(st); s1In.close();
s1.close();
}
}
我想尝试打开yahoo.com.cn的主页,应该怎么做呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货