Main Site Documentation

What scenarios will cause the Socket.Recieve throw an exception?


Using ethernetJ11d, and EthernetBuiltin when running the following code

_socketReceiver.ReceiveFrom(data, ref endPoint);
//some code here

the receive will throw an exception for example when the cable is disconnected.
I can handle this by checking the EthernetBuiltIn .IsCableConnected with and autoResetEvent waiting when detecting that the cable is disconnected and set when cable is reconnected.
the question is what else can cause the receive to throw an exception?


The good place to look is SDK documentation. Each method description page lists what kind of exceptions are thrown by the method.


Well, looks like socket related docs don’t list the exceptions. I would go through the list of socket error codes. These are thrown as SocketExceptions by a socket during its lifetime.


the question is if there’s any indication before running through a loop of exceptions as the cable connected.
since in a regular error I’d like to stop the app but in a legal setup - as cable disconnected I’d like to properly handle it…
so the question is regarding the EthernetBuiltIn if there are any other parameters which can indicate this?


Unfortunately an exception is all you got. Just catch it check the socket error inside the exception and deal with it according with your application logic. There is really nothing else.


@ Devloper123 -

Socket error code can be found at

Link does not work from here?
But works from browser… At least fo me…