日期:2014-05-17 浏览次数:20947 次
class TestServer
{
static void Main()
{
try
{
TCPServer tcpServer = (TCPServer)TCPServer.GetInstance();
tcpServer.ServerIP = "127.0.0.1";
tcpServer.ServerPort = 3721;
tcpServer.CreatListener();
Console.WriteLine(String.Format("Server is ready with {0}:{1}", tcpServer.ServerIP, tcpServer.ServerPort));
}
catch (Exception e)
{
Console.WriteLine("Exception: {0}", e);
}
Console.WriteLine("Press Enter to Exit"); Console.ReadLine();
}
}
public abstract class PacketTransferBase
{
public PacketTransferBase()
{
}
private int count = 0;
/// <summary>
/// 接收信息
/// </summary>
/// <param name="ar"></param>
protected void ReceiveMessage(IAsyncResult ar)
{
try
{
StateObject so = (StateObject)ar.AsyncState;
Socket socket = so.workSocket;
&nbs