Ros_CSharp.TcpTransport.close C# (CSharp) Method

close() public method

public close ( ) : void
return void
        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);
            }
        }
    }

Usage Example

Example #1
0
        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();
            }
        }