methodtAbstractSocket.Close
procedure Close; virtual; abstract;
Tears down the OS handle/events on both client and server sockets; safe to call whether the socket came from Open (client) or Listen/AcceptHandle (server side). Safe from any thread, also while other threads wait on this socket, or are about to: every such WaitForData and WaitForWrite returns at once and answers False - DualWaitForData on Windows answers -1 - and the socket is then no longer Connected, so the waiter's next Receive returns 0. The exception is a WaitForWrite on Windows, which waits in slices of select (10 ms, or the system timer's tick when that is longer, 15.6 ms by default): it can return up to one slice after the Close when it read the socket just before the Close, or when the handle was made elsewhere without WSA_FLAG_OVERLAPPED and given to the constructor (the class makes its own, and those it accepts, with it) - and in that last case the Close itself waits for the slice. A WaitForData or WaitForWrite made after the Close answers False at once.