Beispiel #1
0
        /// <summary>
        /// Build middle server with a given port.
        /// </summary>
        /// <param name="port"></param>
        public UniVRPNityServer(int port = Network.UniVRPNityServerDefaultPort,
            bool verbose = true,
            int updateInterval = DefaultUpdateInterval)
        {
            Console.WriteLine("==== UniVRPNity middle server ====");
            formatter = new BinaryFormatter();
            remotes = new VrpnObjects();
            this.verbose = verbose;
            this.updateInterval = updateInterval;
            //Create a socket for listening connections
            middleServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
            IPEndPoint ipLocal = new IPEndPoint(IPAddress.Loopback, port);

            try
            {
                middleServer.Bind(ipLocal);
                Console.WriteLine("\r Running on port " + port);

                //Run server
                StartListening();

            }
            catch (SocketException)
            {
                Console.Error.WriteLine("Error : Cannot reach " + ipLocal.ToString() + " address at port " + port);
                Console.Error.WriteLine("An other application is probably using this port.");
                Console.ReadKey();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Build middle server with a given port.
        /// </summary>
        /// <param name="port"></param>
        public MiddleVRPNServer(int port = DEFAULT_PORT)
        {
            Console.WriteLine("==== UniVRPNity middle server ====");
            Console.WriteLine("\r Running on port " + port);
            remotes = new VrpnObjects();
            //Create a socket for listening connections
            middleServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
            IPEndPoint ipLocal = new IPEndPoint(IPAddress.Any, port);
            middleServer.Bind(ipLocal);
            formatter = new BinaryFormatter();

            //Run server
            StartListening();
        }