Socket程式中的Error#10054錯誤

來源:互聯網
上載者:User

最近使用winSock做的一個網路項目中,使用TCP+Socket串連編寫的一個多線程的網路程式,功能是用戶端負責不斷地向伺服器端發送資料,服務端負責接收資料。用戶端是一個DLL,服務端程式是一個隨機啟動的NT Service服務程式。

程式在夜間無人操作的運行過程中,用戶端經常不定時地出現錯誤號為:10054錯誤,而伺服器端並沒有相應的提示。運行環境是win2000+sp4,這個問題出現得比較莫名其妙。

查了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來配置一個通訊端。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.