zoukankan      html  css  js  c++  java
  • Socket程序中的Error#10054错误

    测试发现,在Delphi中使用

    str := HTTPFiles.Get(URL + 'UpdateVersions.txt');

    请求文件时,如果

    UpdateVersions.txt内容为空,则会报Error#10054错误。
    分析:
    服务器返回内容为空的报文,然后跟客户机确认,但客户机收到内容为空的报文时,不作为有效报文处理,不进行确认。从而在多次确认无效后,服务器关闭连接。

    查了MSDN上的10054错误号说明:WSAECONNRESET     (10054)   
      Connection   reset   by   peer.      
      A   existing   connection   was   forcibly   closed   by   the   remote   host.   This   normally   results   if   the   peer   application   on   the   remote   host   is   suddenly   stopped,   the   host   is   rebooted,   or   the   remote   host   used   a   "hard   close"   (see   setsockopt   for   more   information   on   the   SO_LINGER   option   on   the   remote   socket.)

     也就是说,一个连接被对方重设。一个建立的连接被远程主机强行关闭,若远程主机上的进程异常终止运行(由于内存冲突或硬件故障),或者针对套接字执行了一次强行关闭,便会产生10054错误。针对强行关闭的情况,可用SO_LINGER套接字选项和setsockopt来配置一个套接字。

  • 相关阅读:
    年少时的"胡思乱想"
    daemon框架
    MVC框架,see again
    《Redis设计与实现》读书笔记
    小胖妞洗发水广告
    项目视图 Project Browser
    Unity 基础
    Unity手册-Unity概述
    rabbitmq 命令&& rabbitmq教程(一)
    C#动态方法调用 提高程序的扩展性
  • 原文地址:https://www.cnblogs.com/qi123/p/9228033.html
Copyright © 2011-2022 走看看