public async Task <int> WaitForConnect() { m_tListener.Start(); Console.WriteLine("Waiting For Connect."); m_tClient = await m_tListener.AcceptTcpClientAsync(); Console.WriteLine("Connected."); NetworkStream ns = m_tClient.GetStream(); stream = new NStream(ref ns); fileTrans = new FileTrans(ref m_tClient, ref ns); return(0); }
public async Task <int> Connect() { IPAddress ipAddress; if (!System.Net.IPAddress.TryParse(IPAddress, out ipAddress)) { return(1); } m_tClient = new TcpClient(); try { await m_tClient.ConnectAsync(ipAddress, Convert.ToInt32(Port)); } catch (Exception e) { return(1); } NetworkStream ns = m_tClient.GetStream(); stream = new NStream(ref ns); fileTrans = new FileTrans(ref m_tClient, ref ns); return(0); }