• Java:网络编程之登陆服务器


    1.
    客服端:浏览器(telnet)
    服务端:自定义
    2.
    客服端:浏览器
    服务端:TomCat服务器
    3.
    客服端:自定义
    服务端:TomCat服务器
     
    //例子如下:
    import java.net.*;
    import java.io.*;
    class ServerDemo
    {
        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='read' 'size'=7>客户端你好</font>");
            
            s.close();
            ss.close();
        }
    }
  • 相关阅读:
    数据访问层之Repository
    IIS执行原理
    异常分析
    Logger
    JSTL
    Kubernetes
    NET Core WordPress
    net平台的rabbitmq
    MySQL can’t specify target table for update in FROM clause
    EqualsBuilder和HashCodeBuilder
  • 原文地址:https://www.cnblogs.com/XYQ-208910/p/4918904.html
Copyright © 2020-2023  润新知