• 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来配置一个套接字。

  • 相关阅读:
    Bit Manipulation
    218. The Skyline Problem
    Template : Two Pointers & Hash -> String process
    239. Sliding Window Maximum
    159. Longest Substring with At Most Two Distinct Characters
    3. Longest Substring Without Repeating Characters
    137. Single Number II
    142. Linked List Cycle II
    41. First Missing Positive
    260. Single Number III
  • 原文地址:https://www.cnblogs.com/qi123/p/9228033.html
Copyright © 2020-2023  润新知