コード例 #1
0
        private void AcceptLoop()
        {
            while (!this.thread.ShouldExit)
            {
                try
                {
                    int client = this.transport.Listen();

                    NetbiosServerConnection connection = this.server.AcceptClient(localEndPoint, client, transport);

                    this.server.AddEvent(new TransportEvent(EventType.Connected, client, this.localEndPoint, this));

                    connection.Start();
                }
                // user stopped the listener.
                catch (InvalidOperationException)
                {
                }
                catch (Exception ex)
                {
                    this.server.AddEvent(new TransportEvent(EventType.Exception, null, ex));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// accept the connected NetbiosClient.
        /// </summary>
        /// <param name="localEP">
        /// an int value that specifies the local listening netbios session id.
        /// </param>
        /// <param name="remoteEP">
        /// an int value that specifies the connected netbios client session id.
        /// </param>
        /// <param name="transport">
        /// a NetbiosTransport object that specifies the owner of client.
        /// </param>
        /// <returns>
        /// a NetbiosServerConnection that specifies the connection.
        /// </returns>
        /// <exception cref="InvalidOperationException">
        /// thrown when invalid connected netbios client.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// thrown when invalid endpoint of connected netbios client
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// thrown when the client specified by endpoint exists
        /// </exception>
        internal NetbiosServerConnection AcceptClient(int localEP, int remoteEP, NetbiosTransport transport)
        {
            if (this.connections.ContainsKey(remoteEP))
            {
                throw new InvalidOperationException("the client specified by endpoint exists");
            }

            NetbiosServerConnection connection = new NetbiosServerConnection(localEP, remoteEP, this, transport);

            this.connections.Add(remoteEP, connection);

            return connection;
        }