Пример #1
0
    private void _ConnectTest()
    {
        Console.WriteLine("Connect test:");

        using (Service svc = new Service("ConnectTest"))
        {
            svc.Start();

            IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7788);

            // Listen
            int listenSessionId = svc.Listen(endPoint);
            Console.WriteLine("Listened on {0}, sessionId: {1}", endPoint, listenSessionId);
            // Synchronous connect.
            int connSessionId = svc.Connect(endPoint);
            Console.WriteLine("Connected to {0}, sessionId: {1}", endPoint, connSessionId);
            // Asynchronous connect.
            svc.AsyncConn(endPoint);
            // Error endpoint's asynchronous connect.
            svc.AsyncConn(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7789));

            Console.WriteLine("Press any key to exit connect test...");
            Console.ReadKey();
        }
    }