Beispiel #1
0
        private async Task NewConnectionsHandler(AsyncQueue <OwnTcpSendMessage> processQueue)
        {
            try
            {
                while (IsOpen)
                {
                    TcpClient client = await listener.AcceptTcpClientAsync().ConfigureAwait(false);

                    OwnTcpSendQueue        queue      = new OwnTcpSendQueue();
                    OwnTcpServerConnection connection = new OwnTcpServerConnection(client, queue);

                    connections.Add(connection);

                    Task sendTask = Task.Run(() => SendClientHandler(connection));
                    Task readTask = Task.Run(() => ReadClientHandler(connection, processQueue));
                    connection.Task = Task.WhenAll(sendTask, readTask);
                }
            }
            catch (Exception e)
            {
                await CloseAsync(e, false);
            }
        }
Beispiel #2
0
 public OwnTcpConnection(TcpClient client)
 {
     Client    = client;
     Stream    = client.GetStream();
     SendQueue = new OwnTcpSendQueue();
 }
Beispiel #3
0
 public OwnTcpServerConnection(TcpClient client, OwnTcpSendQueue sendQueue) : base(client)
 {
 }