예제 #1
0
        internal ClientConnection(Socket socket, TlsSecurityInformation tlsSecInfo, APCIParameters apciParameters, ApplicationLayerParameters parameters, Server server, ASDUQueue asduQueue, bool debugOutput)
        {
            connectionsCounter++;
            connectionID = connectionsCounter;

            this.remoteEndpoint = (IPEndPoint)socket.RemoteEndPoint;

            this.apciParameters = apciParameters;
            this.alParameters   = parameters;
            this.server         = server;
            this.asduQueue      = asduQueue;
            this.debugOutput    = debugOutput;

            ResetT3Timeout();

            maxSentASDUs   = apciParameters.K;
            this.sentASDUs = new SentASDU[maxSentASDUs];

            receivedASDUs        = new ConcurrentQueue <ASDU> ();
            waitingASDUsHighPrio = new Queue <BufferFrame> ();

            socketStream    = new NetworkStream(socket);
            this.socket     = socket;
            this.tlsSecInfo = tlsSecInfo;

            this.fileServer = new FileServer(this, server.GetAvailableFiles(), DebugLog);

            Thread workerThread = new Thread(HandleConnection);

            workerThread.Start();
        }
예제 #2
0
        /// <summary>
        /// Start the server. Listen to client connections.
        /// </summary>
        public void Start()
        {
            IPAddress  ipAddress = IPAddress.Parse(localHostname);
            IPEndPoint localEP   = new IPEndPoint(ipAddress, localPort);

            // Create a TCP/IP  socket.
            listeningSocket = new Socket(AddressFamily.InterNetwork,
                                         SocketType.Stream, ProtocolType.Tcp);

            listeningSocket.Bind(localEP);

            listeningSocket.Listen(100);

            Thread acceptThread = new Thread(ServerAcceptThread);

            if (serverMode == ServerMode.SINGLE_REDUNDANCY_GROUP)
            {
                asduQueue = new ASDUQueue(maxQueueSize, alParameters, DebugLog);
            }

            acceptThread.Start();
        }