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

        public tcpClient()
        {
            conn_ = new tcpConnection(AddressFamily.InterNetwork,
                                      SocketType.Stream,
                                      ProtocolType.Tcp);
        }
Esempio 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            );
        }