/// <summary> /// Start the server /// </summary> /// <param name="host">Hostname to use for this server (DNS/IP)</param> /// <param name="port">The port number to listen on</param> public override void Initialize(string host, int port) { this._host = (host == null || host.Trim().Length == 0) ? "unknown" : host; if (port <= 0) { this._port = AbstractNetworkUtils.GetDefaultCoAPPort(); } else { this._port = port; } Shutdown(); //close all previous connections //Create the wait q this._msgPendingAckQ = new TimedQueue((uint)AbstractCoAPChannel.DEFAULT_ACK_TIMEOUT_SECS); this._msgPendingAckQ.OnResponseTimeout += new TimedQueue.TimedOutWaitingForResponse(OnTimedOutWaitingForResponse); //Create the separate response q this._separateResponseQ = new SeparateResponseQueue(); //Create the observers list this._observers = new ObserversList(); // Create a socket, bind it to the server's port and listen for client connections this._isDone = false; this.ReInitSocket(); Thread waitForClientThread = new Thread(new ThreadStart(WaitForConnections)); waitForClientThread.Start(); }
/// <summary> /// Shutdown the client channel /// </summary> public override void Shutdown() { this._isDone = true; if (this._socket != null) { this._socket.Close(); this._socket = null; } if (this._msgPendingAckQ != null) { this._msgPendingAckQ.Shutdown(); } this._msgPendingAckQ = null; this._separateResponseQ = null; this._observers = null; }