Esempio n. 1
0
        static void Listen()
        {
            SocketCpp socket = null;

            SocketCpp clientSocket;

            Thread thread;

            try
            {
                socket = SocketCpp.CreateAndListen("127.0.0.1", "9527");

                while (true)
                {
                    clientSocket = socket.Accept();

                    thread = new Thread(Receive);

                    thread.Start(clientSocket);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Listen while error: " + ex.ToString());
            }


            Console.WriteLine("Listen Close.");


            if (socket != null)
            {
                socket.Shutdown(SocketShutdown.Both);
                socket.Close();
            }

            SocketCpp.WSACleanup();
        }