Example #1
0
        //const int tcpPort = 5198;
        //const int udpPort = 5530;
        //const string ipaddress = "118.25.68.161";

        //const string ipaddress = ConfigurationManager.AppSettings["ipaddress"].ToString();

        ///const string ipaddress = "115.29.231.29";



        ///const string ipaddress = "121.40.53.77";
        static void Main(string[] args)
        {
            ///端口正在被占用
            if (IsPortOccupedFun2(4198, 4530, 4531, 4532, 4533))
            {
                Environment.Exit(0);
            }

            else
            {
                string ipaddress = ConfigurationManager.AppSettings["ipaddress"].ToString();
                try
                {
                    TUdpServer udpServer = new TUdpServer();
                    udpServer.UdpStart(ipaddress, udpPort);

                    MTcpServer tcpServer = new MTcpServer();
                    tcpServer.Start(ipaddress, tcpPort);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    //LogHelper.Info("program运行错误:" + ex.Message);
                    Environment.Exit(0);
                }
            }
            Console.Read();
        }
Example #2
0
        public void TUdpClientStaticSendTest()
        {
            TUdpServer server = new TUdpServer(900);

            server.UdpReceiveString += (s, e) =>
            {
                var b = e.Equals("Hello");
                Assert.IsTrue(!b);
            };
            TUdpClient.StaticSend("127.0.0.1", 900, "Hello");
            System.Threading.Thread.Sleep(100);
        }