zoukankan      html  css  js  c++  java
  • 网络timeout区分

    ConnectTimeout

    连接建立时间,三次握手完成时间

    SocketTimeout

    数据传输过程中数据包之间间隔的最大时间

    下面重点说下SocketTimeout,比如有如下图所示的http请求

    这里写图片描述

    虽然报文(“abc”)返回总共用了6秒,如果SocketTimeout设置成4秒,实际程序执行的时候是不会抛出java.net.SocketTimeoutException: Read timed out异常的。

    因为SocketTimeout的值表示的是“a”、”b”、”c”这三个报文,每两个相邻的报文的间隔时间不能超过SocketTimeout

    ReadTimeout

    2. ReadTimeout , java 是这样解释的。 意思是已经建立连接,并开始读取服务端资源。如果到了指定的时间,没有可能的数据被客户端读取,则报异常。

    [java] view plain copy
    1. Sets the read timeout to a specified timeout, in milliseconds. A non-zero value specifies the timeout when reading from Input stream when a connection is established to a resource. If the timeout expires before there is data available for read, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.   
    2.   
    3. Some non-standard implementation of this method ignores the specified timeout. To see the read timeout set, please call getReadTimeout().  
  • 相关阅读:
    关于螺旋矩阵的问题
    JDK 1.5 for 循环的新写法
    Java基础视频笔记(三)
    关于接口的理解
    常用的DOS命令
    Java基础视频笔记(二)
    Eclipse的常用快捷键备忘
    Java基础视频笔记(四):泛型
    异常设计准则
    多重继承和虚继承的内存布局(转)
  • 原文地址:https://www.cnblogs.com/zhaoxinshanwei/p/9071804.html
Copyright © 2011-2022 走看看