Socket.Close() function blocks G400 for a minute

If I call Socket.Close() method on a possibly non-functional socket (like, for example, when the other side crashes), the whole G400 locks up for quite a lengthy amount of time — sometimes for a minute. This shouldn’t be considered a normal behaviour?

Blocking the whole program for a minute is already a bad thing by itself, but for me it is even worse. CAN bus routines are still working somewhere at the firmware level, quickly overruning all the buffers and breaking something inside so G400 doesn’t recover at all, if Socket.Close() takes too long…

Any ideas?..

It is a good idea to always keep the networking code in a separate thread. And to not call networking methods from within events.

I have a few threads, and[em] they all are blocked[/em] once Socket.Close() is called.

@ Simon from Vilnius -

I made a simple test with both udp / tcp protocal type, connected success and unsuccess, try to call Close it, but it is still working well, just an exception if connection was unsuccessful (wrong ip address, disconnected cable etc…)

I am not sure how you define “non-functional socket”, can you post a simple code please?