예제 #1
0
        static void Main(string[] args)
        {
            //DateTime? dt = GetStandardDataTime();
            //if (dt != null)
            //{
            //    DateTime localTime = Convert.ToDateTime(dt).AddHours(8);
            //    TimeSpan ts = localTime - DateTime.Now;
            //    if (Math.Abs(ts.Hours) > 0)
            //    {
                    //set system time
            //    }
            //}
            try
            {
                Int32 port = 5689;
                Int32 numConnections = 10;
                Int32 bufferSize = Int16.MaxValue;

                SocketListener sl = new SocketListener(numConnections, bufferSize);
                sl.Start(port);

                Console.WriteLine("Server listening on port {0}. Press any key to terminate the server process...", port);
                Console.Read();

                sl.Stop();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }