public VncServer(int listenerPort = 0) : base(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) { working = true; ListenerPortOfServer = listenerPort; if (listenerPort == 0) { listenerPort = PortUtils.GetFreePort(); } Bind(new IPEndPoint(IPAddress.Any, listenerPort)); Listen(Constants.MAX_PENDING_CONNECTION); DataArrived += new DataArrivedEventHandler(DataArrivedHandler); Task.Factory.StartNew(() => { ListenerEngine(); }); Task.Factory.StartNew(() => { ScreenSender(); }); }