zoukankan      html  css  js  c++  java
  • java8--网络编程(java疯狂讲义3复习笔记)

    重点复习一下网络通信和代理

    java的网络通信很简单,服务器端通过ServerSocket建立监听,客户端通过Socket连接到指定服务器后,通信双方就可以通过IO流进行通信.

    需要重点看的工具类:InetAddress,URLDecoder,URLEncoder,URL和URLConnetion等

    TCP/IP分层模型:应用层(比如http),传输层(比如TCP),网络层(比如IP),物理+数据链路层

    IP地址是一个32位(bit)整数,为了便于记忆,分成4个8位的二进制数,每8位之间用圆点隔开,每个8位整数可以转换成一个0~255的十进制整数,因此看到的ip是这种形式 : 172.20.15.181

    public class NetWorkLearn {
        public static void main(String[] args) throws Exception{
            InetAddress ip = InetAddress.getByName("www.crazyit.org");
            System.out.println(" 可达否:" + ip.isReachable(2000));
            System.out.println(ip.getCanonicalHostName());
            System.out.println(ip.getHostAddress());
            InetAddress local = InetAddress.getByAddress(new byte[]{127,0,0,1});
            System.out.println("本机可达:"+local.isReachable(2000));
            System.out.println(local.getCanonicalHostName());
            }
    }
    
    -----------------------------------------------------------------
     可达否:true
    www.crazyit.org
    222.73.85.205
    本机可达:true
    localhost

    URLDecoder类包含一个decode(String s, String enc)静态方法,它可以将看上去是URL编码的特殊字符串转换成普通字符串

    URLEncoder类包含一个encoder(String s,String enc)静态方法,它可以将普通字符串转换成url编码.

    URL: Uniform Resource Locator ,统一资源定位器.

  • 相关阅读:
    关于TensorFlow2的tf.function()和AutoGraph的一些问题解决
    voxelmorph配置
    python处理nii格式文件
    mysql总结
    JVM内存模型
    Java线程池面试
    java NIO基础
    面试日记
    PhoenixFD插件流体模拟——UI布局【Gird】详解
    PhoenixFD插件流体模拟——UI布局【Resimulation】详解
  • 原文地址:https://www.cnblogs.com/lakeslove/p/5972403.html
Copyright © 2011-2022 走看看