I am wondering if in my Async Sockets in C #, getting 0 bytes in an EndRead call, does the server really disconnect us?
Many of the examples that I see show that this is so, but I get disconnects much more often than I expected.
Is this code correct? Or does endResult <= 0 mean nothing about the state of the connection?
private void socket_EndRead(IAsyncResult asyncResult) { //Get the socket from the result state Socket socket = asyncResult.AsyncState as Socket; //End the read int endResult = Socket.EndRead(asyncResult); if (endResult > 0) { //Do something with the data here } else { //Server closed connection? } }
0 read length should mean a graceful shutdown. Disable throws error (10054, 10053 or 10051).
, , 0, , - 0 . : . , , . , , , , 995 ERROR_OPERATION_ABORTED, . , , , (.. ) 995, 0.
ERROR_OPERATION_ABORTED
:
Socket , EndRead .
, , .
Source: https://habr.com/ru/post/1717168/More articles:What are the consequences of disabling Oracle rollforward logs in Hibernate? - oracleInheritance of inheritance classes - inheritanceEnable sys, guest, and information_schema users in SQL Server - sql-serverhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1717166/binding-entities-to-a-windows-datagridview&usg=ALkJrhin8zCRGucz15sa40gFAgHGWtIIAQPlanning to create PDF files in Ruby on Rails - ruby-on-railsOctave + GNUPlot + Aquaterm + Mac OS 10.6 - unixWhat open source licenses allow you to distribute a binary executable / library without copyright notice? - licensingCall cross-threading user interface component - multithreadingA new vector based on a comparison of the elements of two other vectors "lagged"? - rHow to determine if a phone application is available for various devices using iphone os - iphoneAll Articles