System.Net.Sockets.TcpListener.BeginAcceptSocket C# (CSharp) Méthode

BeginAcceptSocket() public méthode

public BeginAcceptSocket ( AsyncCallback callback, object state ) : IAsyncResult
callback AsyncCallback
state object
Résultat IAsyncResult
        public IAsyncResult BeginAcceptSocket(AsyncCallback callback, object state)
        {
            if (NetEventSource.IsEnabled) NetEventSource.Enter(this);

            if (!_active)
            {
                throw new InvalidOperationException(SR.net_stopped);
            }

            IAsyncResult result = _serverSocket.BeginAccept(callback, state);

            if (NetEventSource.IsEnabled) NetEventSource.Exit(this);
            return result;
        }

Usage Example

Exemple #1
0
        static void Main(string[] args)
        {
            GMSKeys.Initialize();

            {
                // Quick test
                ITEMS = new Dictionary<short, ItemEquip>();
                ITEMS.Add(1, new ItemEquip(1113017)
                {
                    StatusFlags = 0x0714,
                    Potential1 = 40356,
                    Potential2 = 30041,
                    Potential3 = 30044,
                    Potential4 = 12011,
                    Potential5 = 2014,
                    Potential6 = 2014,
                    SocketState = 0x00FF,
                    Nebulite2 = 1001,
                    Nebulite1 = 2001,
                    Nebulite3 = 3400,

                });

                //File.WriteAllText("import.xml", ITEMS.Serialize());

                if (File.Exists("import.xml"))
                {
                    ITEMS = File.ReadAllText("import.xml").Deserialize<Dictionary<short, ItemEquip>>();
                }
            }

            if (ITEMS == null)
                ITEMS = new Dictionary<short, ItemEquip>();

            {
                TcpListener listener = new TcpListener(System.Net.IPAddress.Any, 8484);
                listener.Start();

                AsyncCallback EndAccept = null;
                EndAccept = (a) =>
                {
                    new Client(listener.EndAcceptSocket(a));

                    Console.WriteLine("accepted");

                    listener.BeginAcceptSocket(EndAccept, null);
                };

                listener.BeginAcceptSocket(EndAccept, null);
            }



            Console.ReadLine();
        }
All Usage Examples Of System.Net.Sockets.TcpListener::BeginAcceptSocket