Ejemplo n.º 1
0
        public bool Open()
        {
            string listener_addr = ConfigurationSettings.AppSettings["listener_addr"];

            string listener_port = ConfigurationSettings.AppSettings["listener_port"];

            string session_count = ConfigurationSettings.AppSettings["session_count"];

            FSessionManager = new GSSessionManager(Convert.ToInt32(session_count), 1);

            FAcceptSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            IPAddress addr = IPAddress.Parse(listener_addr);

            IPEndPoint ep = new IPEndPoint(addr, Convert.ToInt32(listener_port));

            FAcceptSock.Bind(ep);

            FAcceptSock.Listen(1000);

            Accept();

            return true;
        }
Ejemplo n.º 2
0
        public GSSession(GSSessionManager manager)
        {
            FSessionManager = manager;

            FPacketHandler = new SessionPacketHandler(this);

            FPacketSpliter = new PacketSpliter();

            FPacketSpliter.OnPacket += FPacketHandler.OnPacket; ;

            FSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            FAcceptEventArg = new SocketAsyncEventArgs();

            FAcceptEventArg.AcceptSocket = FSock;

            FAcceptEventArg.Completed += OnCompleted;

            FAcceptEventArg.UserToken = this;

            FBufferManager = new SockBufferManager();

            FBufferManager.Initialize(10, 10);
        }