美文网首页
java搭建一个简单的服务器

java搭建一个简单的服务器

作者: Yuu_CX | 来源:发表于2016-11-24 10:54 被阅读0次
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

相关文章

网友评论

      本文标题:java搭建一个简单的服务器

      本文链接:https://www.haomeiwen.com/subject/tfsbpttx.html