private new void Dispose() { #if cooper if (!fIsServer) { fHandle.close(); } else { fServerHandle.close(); } #else #if posix || toffee || darwin if (rtl.close(fHandle) != 0) { throw new Exception("Error closing socket"); } #else if (rtl.closesocket(fHandle) != 0) { throw new Exception("Error closing socket"); } #endif #endif Connected = false; }
public void Close_internal(out int error) { error = 0; if (jServerSocket != null) { try { jServerSocket.close(); } catch (Exception e) { error = 10022; //WSAEINVAL (Invalid argument) #if DEBUG Console.WriteLine("Caught exception during Close_internal jServerSocket - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace); #endif } try { jServerSocketChannel.close(); } catch (Exception e) { error = 10022; //WSAEINVAL (Invalid argument) #if DEBUG Console.WriteLine("Caught exception during Close_internal jServerSocketChannel - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace); #endif } jServerSocket = null; jServerSocketChannel = null; } else if (jSocket != null) { try { jSocket.close(); } catch (Exception e) { error = 10022; //WSAEINVAL (Invalid argument) #if DEBUG Console.WriteLine("Caught exception during Close_internal jSocket - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace); #endif } try { jSocketChannel.close(); } catch (Exception e) { error = 10022; //WSAEINVAL (Invalid argument) #if DEBUG Console.WriteLine("Caught exception during Close_internal jSocketChannel - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace); #endif } jSocket = null; jSocketChannel = null; } }