java搭建一个简单的服务器

2016-11-24  本文已影响0人  Yuu_CX
public class TestDemo {
    public static void main(String[] args) throws Exception {
        ServerSocket ss = new ServerSocket(8080);
        Socket s = ss.accept();
        System.out.println(s.getInetAddress().getHostAddress());
        InputStream in = s.getInputStream();
        byte[] buf = new byte[1024];
        int len = in.read(buf);
        System.out.println(new String(buf,0,len));
        PrintWriter out = new PrintWriter(s.getOutputStream(),true);
        out.println("<font color='red' size='8'>提交成功</font>");
        s.close();
        ss.close();
    }
}

则服务器地址为 http://202.38.203.174:8080

上一篇 下一篇

猜你喜欢

热点阅读