Listen() public méthode

Start to Listen.
public Listen ( string host, int port ) : void
host string
port int
Résultat void
Exemple #1
0
        /// <summary>
        /// Wait for a connection from VNC Server.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="port"></param>
        /// <param name="viewOnly"></param>
        public void Listen(string host, int port, bool viewOnly)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }

            rfb = new RfbProtocol();

            if (viewOnly)
            {
                inputPolicy = new VncViewInputPolicy(rfb);
            }
            else
            {
                inputPolicy = new VncDefaultInputPolicy(rfb);
            }

            // Connect and determine version of server, and set client protocol version to match
            try
            {
                rfb.RfbConnectedFromServer += new EventHandler(ConnectedFromServerEventHandler);
                rfb.FailedToListen         += new EventHandler(FailedToListenHandler);
                rfb.Listen(host, port);
            }
            catch (Exception)
            {
                if (ConnectionLost != null)
                {
                    ConnectionLost(this, EventArgs.Empty);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Main Function for Connect Process.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="display"></param>
        /// <param name="port"></param>
        /// <param name="viewOnly"></param>
        /// <param name="connectFromClient">Set true if connect from client to server. Set false if wait for a connection from server.</param>
        /// <returns></returns>
        private bool ConnectCore(string host, int display, ref int port, bool viewOnly, bool connectFromClient)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }

            // If a diplay number is specified (used to connectFromClient to Unix servers)
            // it must be 0 or greater.  This gets added to the default port number
            // in order to determine where the server will be listening for connections.
            if (display < 0)
            {
                throw new ArgumentOutOfRangeException("display", display, "Display number must be non-negative.");
            }
            port += display;

            rfb = new RfbProtocol();

            if (viewOnly)
            {
                inputPolicy = new VncViewInputPolicy(rfb);
            }
            else
            {
                inputPolicy = new VncDefaultInputPolicy(rfb);
            }

            // Connect and determine version of server, and set client protocol version to match
            try
            {
                if (connectFromClient)
                {
                    rfb.Connect(host, port);
                    return(DoHandShake());
                }
                else
                {
                    rfb.Listen(host, port);
                    return(true);
                }
            }
            catch (Exception e)
            {
                throw new VncProtocolException("Unable to connect to the server. Error was: " + e.Message, e);
            }
        }
Exemple #3
0
        /// <summary>
        /// Wait for a connection from VNC Server.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="port"></param>
        /// <param name="viewOnly"></param>
        public void Listen(string host, int port, bool viewOnly)
        {
            if (host == null) throw new ArgumentNullException("host");

			rfb = new RfbProtocol();

			if (viewOnly) {
				inputPolicy = new VncViewInputPolicy(rfb);
			} else {
				inputPolicy = new VncDefaultInputPolicy(rfb);
			}
			
			// Connect and determine version of server, and set client protocol version to match			
            try
            {
                rfb.RfbConnectedFromServer += new EventHandler(ConnectedFromServerEventHandler);
                rfb.FailedToListen += new EventHandler(FailedToListenHandler);
                rfb.Listen(host, port);
            } 
            catch (Exception)
            {
                if (ConnectionLost != null)
                {
                    ConnectionLost(this, EventArgs.Empty);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Main Function for Connect Process.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="display"></param>
        /// <param name="port"></param>
        /// <param name="viewOnly"></param>
        /// <param name="connectFromClient">Set true if connect from client to server. Set false if wait for a connection from server.</param>
        /// <returns></returns>
        private bool ConnectCore(string host, int display, ref int port, bool viewOnly, bool connectFromClient)
        {
            if (host == null) throw new ArgumentNullException("host");

            // If a diplay number is specified (used to connectFromClient to Unix servers)
            // it must be 0 or greater.  This gets added to the default port number
            // in order to determine where the server will be listening for connections.
            if (display < 0) throw new ArgumentOutOfRangeException("display", display, "Display number must be non-negative.");
            port += display;

            rfb = new RfbProtocol();

            if (viewOnly)
            {
                inputPolicy = new VncViewInputPolicy(rfb);
            }
            else
            {
                inputPolicy = new VncDefaultInputPolicy(rfb);
            }

            // Connect and determine version of server, and set client protocol version to match			
            try
            {
                if (connectFromClient)
                {
                    rfb.Connect(host, port);
                    return DoHandShake();
                }
                else
                {
                    rfb.Listen(host, port);
                    return true;
                }                
            }
            catch (Exception e)
            {
                throw new VncProtocolException("Unable to connect to the server. Error was: " + e.Message, e);
            }
        }