protected void onClientConnect(IAsyncResult res) { try { tcpConnection conn = new tcpConnection(listener_.EndAccept(res)); IPEndPoint endPoint = (IPEndPoint)conn.socket.RemoteEndPoint; connections_.Add(Dns.GetHostEntry(endPoint.Address).HostName, conn); Console.WriteLine( DateTime.Now.ToString() + " new connection from " + Dns.GetHostEntry(endPoint.Address).HostName); } catch (Exception e) { Console.WriteLine( DateTime.Now.ToString() + " new connection attempt failed: " + e.Message); } finally { listener_.BeginAccept(new AsyncCallback(onClientConnect), null); } }
internal tcpConnection conn_; // connection to the remote host public tcpClient() { conn_ = new tcpConnection(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); }
internal tcpConnection conn_; // connection to the remote host #endregion Fields #region Constructors public tcpClient() { conn_ = new tcpConnection( AddressFamily.InterNetwork , SocketType.Stream , ProtocolType.Tcp ); }