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來配置一個套接字。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM