static void Main(string[] args) { Console.WriteLine("Proc Server?(Y/N)"); string str = Console.ReadLine(); if (str == "Y" || str == "y") { Ser ser = new Ser(); ser.Run(); } else { Client cl = new Client(); cl.Run(); } }
public void Run() { Console.WriteLine("=====客户端===="); Console.WriteLine("输入连接 mark:"); int mark = Ser.GetMark(); m_SocketClient.Start((byte)mark, "127.0.0.1", 1234, this); while (true) { Console.WriteLine("输入向服务器发送内容:"); String str = Console.ReadLine(); byte[] bytes = Encoding.Default.GetBytes(str); m_SocketClient.Send(0, bytes, (UInt32)bytes.Length); } }
public void Run() { Console.WriteLine("=====服务器===="); bool localAddr = false; bool singleModel = false; Console.WriteLine("localAddr Server?(Y/N)"); string str = Console.ReadLine(); if (str == "Y" || str == "y") { localAddr = true; } Console.WriteLine("singleModel Server?(Y/N)"); str = Console.ReadLine(); if (str == "Y" || str == "y") { singleModel = true; } m_SocketServer.Start(1234, this, localAddr, singleModel); while (true) { Console.WriteLine("输入客户端 mark:"); int mark = Ser.GetMark(); Console.WriteLine("输入向客户端发送内容:"); str = Console.ReadLine(); byte[] bytes = Encoding.Default.GetBytes(str); m_SocketServer.SendToMarkConn((byte)mark, 0, bytes, (UInt32)bytes.Length); } }