Esempio n. 1
0
        private void ServerThread(object state)
        {
            try
            {
                Socket streamingServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                streamingServer.Bind(new IPEndPoint(IPAddress.Any, (int)state));
                streamingServer.Listen(10);

                Debug.Log($"ImageServer::Server started on port {state}.");

                foreach (Socket client in streamingServer.AcceptIncomingConnections())
                {
                    ThreadPool.QueueUserWorkItem(new WaitCallback(ClientThread), client);
                }
            }
            catch (Exception exception)
            {
                Debug.LogError(exception);
            }

            Stop();
        }