Exemplo n.º 1
0
        public void BeginRead(ConnectionContextTPL connectionContext)
        {
            InputStreamContext ctx = new InputStreamContext(connectionContext, bufferSize);

            Task<int>.Factory.FromAsync<byte[], int, int>(ctx.ConnectionContext.ClientStream.BeginRead,
                ctx.ConnectionContext.ClientStream.EndRead, ctx.Header, 0, sizeof(long), ctx).ContinueWith(BeginReadCallback);
        }
 public OutputStreamContext(ConnectionContextTPL connectionContext)
 {
     this.connectionContext = connectionContext;
 }
Exemplo n.º 3
0
        private void BeginAcceptSocketCallback(IAsyncResult result)
        {
            Log.LogMessage("Received socket connection");

            TcpListener tcpListener = (TcpListener)result.AsyncState;
            TcpClient tcpClient = tcpListener.EndAcceptTcpClient(result);
            tcpClient.SendTimeout = 10000;
            tcpClient.ReceiveTimeout = 10000;
            NetworkStream clientStream = tcpClient.GetStream();

            ConnectionContextTPL ctx = new ConnectionContextTPL(clientStream, ConnString, this, Log);
            ctx.StartProcessingInputQueue();
            BeginRead(ctx);

            tcpListener.BeginAcceptTcpClient(BeginAcceptSocketCallback, tcpListener);
        }
 public InputStreamContext(ConnectionContextTPL connectionContext, int bufferSize)
 {
     this.connectionContext = connectionContext;
     this.buffer = new byte[bufferSize];
 }