How to find out the cause of Socket.Select () reporting an error

I call Bind()and then Listen()in System.Net.Sockets.Socket. None of these calls raise an exception.

Later I call:

Socket.Select(myreadlist,mywritelist,myerrorlist,0);

with myreadlist and myerrorlist containing the corresponding socket. Select the report of my socket as having an error, leaving the socket in errorList, instead of removing it from the list. Nowhere in the program throws a SocketException.

I can’t figure out how to access the system correctly: “okay, so what went wrong?”

Somebody knows?

Thanks Lucas

edit: add 4th argument = 0 to select + explained better how select () tells me that an error has occurred.

+3
source share
2 answers

#, UNIX-. , accept() , , ( , , ) , , . , , : -)

, MSDN , Google ( "#" ), :

If you receive a SocketException, use SocketException.ErrorCode to obtain the specific error code. Once you have obtained this code, you can refer to the Windows Socket Version 2 API error code documentation in MSDN for a detailed description of the error.

, , , Google ( API Windows Socket Version 2 MSDN).

Google , MSDN . , , . , ( , : -).

, : , , , . . , , #, - (, , ).

, -1 ( - -1): . , -1 , . -2, , , , .

, myerrorlist, . , , , , .

  • WSA (, WSAGetLastError()), . , #. accept() , , , .
  • Socket Handle, . , , .
  • select() (.. accept(), )?

, , . , , ..NET 2, -, select(), .

+1

Select() :

, checkerror , .

Poll() ( ) SelectError :

true, , , ; -- true, OutOfBandInline ; false.

, , , , . Connect(), , , . , , , - .

0

Source: https://habr.com/ru/post/1703276/


All Articles