internal ServerConnection(Socket socket, ConnectionParameters parameters, Server server, ASDUQueue asduQueue, bool debugOutput) { connectionsCounter++; connectionID = connectionsCounter; this.socket = socket; this.parameters = parameters; this.server = server; this.asduQueue = asduQueue; this.debugOutput = debugOutput; ResetT3Timeout(); maxSentASDUs = parameters.K; this.sentASDUs = new SentASDU[maxSentASDUs]; //TODO only needed when connection is activated receivedASDUs = new Queue <ASDU> (); waitingASDUsHighPrio = new Queue <BufferFrame> (); Thread workerThread = new Thread(HandleConnection); callbackThread = new Thread(ProcessASDUs); workerThread.Start(); callbackThread.Start(); }
internal ServerConnection(Socket socket, TlsSecurityInformation tlsSecInfo, ConnectionParameters parameters, Server server, ASDUQueue asduQueue, bool debugOutput) { connectionsCounter++; connectionID = connectionsCounter; this.parameters = parameters; this.server = server; this.asduQueue = asduQueue; this.debugOutput = debugOutput; ResetT3Timeout(); maxSentASDUs = parameters.K; this.sentASDUs = new SentASDU[maxSentASDUs]; //TODO only needed when connection is activated receivedASDUs = new Queue <ASDU> (); waitingASDUsHighPrio = new Queue <BufferFrame> (); socketStream = new NetworkStream(socket); this.socket = socket; this.tlsSecInfo = tlsSecInfo; Thread workerThread = new Thread(HandleConnection); workerThread.Start(); }
/// <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, parameters, DebugLog); } acceptThread.Start(); }