示例#1
0
        public int Start()
        {
            listener = new TcpListener(endPoint);
            if (endPoint.Address.AddressFamily == AddressFamily.InterNetworkV6)
            {
                listener.Server.DualMode = true;
            }
            listener.Start();

            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                // set socket handle as not inherited so that when tentacle runs powershell
                // with System.Diagnostics.Process those scripts don't lock the socket
                SetHandleInformation(listener.Server.Handle, HANDLE_FLAGS.INHERIT, HANDLE_FLAGS.None);
            }

            log = logFactory.ForEndpoint(new Uri("listen://" + listener.LocalEndpoint));
            log.Write(EventType.ListenerStarted, "Listener started");

            new Thread(Accept)
            {
                Name = "Accept connections on " + listener.LocalEndpoint
            }.Start();

            return(((IPEndPoint)listener.LocalEndpoint).Port);
        }
示例#2
0
 public int Start()
 {
     listener = new TcpListener(endPoint);
     listener.Start();
     log = logFactory.ForEndpoint(new Uri("listen://" + listener.LocalEndpoint));
     log.Write(EventType.ListenerStarted, "Listener started");
     Accept();
     return(((IPEndPoint)listener.LocalEndpoint).Port);
 }
示例#3
0
        public int Start()
        {
            listener = new TcpListener(endPoint);
            if (endPoint.Address.AddressFamily == AddressFamily.InterNetworkV6)
            {
                listener.Server.DualMode = true;
            }
            listener.Start();

#if CAN_GET_SOCKET_HANDLE
            // set socket handle as not inherited so that when tentacle runs powershell
            // with System.Diagnostics.Process those scripts don't lock the socket
            SetHandleInformation(listener.Server.Handle, HANDLE_FLAGS.INHERIT, HANDLE_FLAGS.None);
#endif

            log = logFactory.ForEndpoint(new Uri("listen://" + listener.LocalEndpoint));
            log.Write(EventType.ListenerStarted, "Listener started");
            Task.Run(async() => await Accept());
            return(((IPEndPoint)listener.LocalEndpoint).Port);
        }