//我在浏览器中输入的是 http://192.168.1.3:8080 服务器中会读取ip,但浏览器中没服务器输出的“你好";
import java.net.*;
import java.io.*;
class java04
{
public static void main(String[] args) throws IOException
{
ServerSocket ss=new ServerSocket(8080);//主机:192.168.1.3
Socket s=ss.accept();
String ip=s.getInetAddress().getHostAddress();
System.out.println(ip);
PrintWriter pw=new PrintWriter(s.getOutputStream(),true);
pw.println("你好");
s.close();
ss.close();
}
}
|
|