Exemplo n.º 1
1
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        internal tcpConnection conn_;                        // connection to the remote host

        public tcpClient()
        {
            conn_ = new tcpConnection(AddressFamily.InterNetwork,
                                      SocketType.Stream,
                                      ProtocolType.Tcp);
        }
Exemplo n.º 4
0
        internal tcpConnection conn_; // connection to the remote host

        #endregion Fields

        #region Constructors

        public tcpClient()
        {
            conn_ = new tcpConnection(  AddressFamily.InterNetwork  ,
                                        SocketType.Stream           ,
                                        ProtocolType.Tcp            );
        }