private Task ConnectAsyncCore(IPAddress address, int port) { return Task.Factory.FromAsync( (targetAddess, targetPort, callback, state) => ((TcpClient)state).BeginConnect(targetAddess, targetPort, callback, state), asyncResult => ((TcpClient)asyncResult.AsyncState).EndConnect(asyncResult), address, port, state: this); }