Example #1
0
        public void Connect(IPEndPoint endpoint, TcpSocketConnectCallback callback)
        {
            TcpSocketConnectRoutine routine = new TcpSocketConnectRoutine(handle, worker, endpoint);
            TcpSocketConnectResult  result  = new TcpSocketConnectResult
            {
                Handle      = handle,
                Socket      = this,
                Endpoint    = endpoint,
                OnConnected = callback
            };

            routine.Execute(result);
        }
Example #2
0
        public Task <TcpSocketConnect> Connect(IPEndPoint endpoint)
        {
            TcpSocketConnectResult result = new TcpSocketConnectResult
            {
                Socket   = this,
                Handle   = handle,
                Endpoint = endpoint,
                Event    = new ManualResetEvent(false)
            };

            TcpSocketConnectRoutine routine = new TcpSocketConnectRoutine(handle, worker, endpoint);
            Task <TcpSocketConnect> task    = Task.Factory.FromAsync(result, result.Unpack);

            routine.Execute(result);
            return(task);
        }