public void close() { DisconnectFunc disconnect_cb = null; lock (close_mutex) { if (!closed) { closed = true; if (poll_set != null) poll_set.delSocket(sock); if (sock.Connected) sock.Shutdown(SocketShutdown.Both); sock.Close(); sock = null; disconnect_cb = this.disconnect_cb; this.disconnect_cb = null; read_cb = null; write_cb = null; accept_cb = null; } } if (disconnect_cb != null) { disconnect_cb(this); } } }
public void drop(DropReason reason) { bool did_drop = false; if (!dropped) { dropped = true; did_drop = true; if (DroppedEvent != null) { DroppedEvent(this, reason); } } if (did_drop) { transport.close(); } }