当前位置: 首页>>代码示例>>C#>>正文


C# Service.Connect方法代码示例

本文整理汇总了C#中Service.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# Service.Connect方法的具体用法?C# Service.Connect怎么用?C# Service.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Service的用法示例。


在下文中一共展示了Service.Connect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _ConnectTest

    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();
        }
    }
开发者ID:lailongwei,项目名称:llbc,代码行数:25,代码来源:TestCase_Comm_Service.cs

示例2: _SendRecvTest

    private void _SendRecvTest()
    {
        Console.WriteLine("Send/Recv test:");
        using (Service svc = new Service("SendRecvTest"))
        {
            svc.Start();

            IPEndPoint ep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7788);
            int listenSessionId = svc.Listen(ep);
            Console.WriteLine("Listened on [{0}], sessionId: {1}", ep, listenSessionId);

            int connSessionId = svc.Connect(ep);
            Console.WriteLine("Connected to {0}, sessionId: {1}", ep, connSessionId);

            // Test Send
            TestPacket data = new TestPacket();
            data.intVal = 10086;
            data.strVal = "Hello World";
            svc.Send(connSessionId, data);

            // Test Multicast
            TestMulticastPacket multicastData = new TestMulticastPacket();
            multicastData.intVal = 10010;
            multicastData.strVal = "Multicast data";
            List<int> multicastSessionIds = new List<int>();
            multicastSessionIds.Add(connSessionId);
            svc.Multicast(multicastSessionIds, multicastData);

            // Test Broadcast
            TestBroadcastPacket broadcastData = new TestBroadcastPacket();
            broadcastData.intVal = 8888;
            broadcastData.strVal = "Broadcast data";
            svc.Broadcast(broadcastData);

            // Test unhandled packet
            svc.Send(connSessionId, new UnHandledPacket());

            // Test coder not found
            MemoryStream unhandledStream = new MemoryStream();
            unhandledStream.Write(new byte[30], 0, 30);
            svc.Send(connSessionId, 10086, unhandledStream);

            Console.WriteLine("Press any key to exit Send/Recv test...");
            Console.ReadKey();
        }
    }
开发者ID:lailongwei,项目名称:llbc,代码行数:46,代码来源:TestCase_Comm_Service.cs

示例3: CiraTecnicalTest

        private void CiraTecnicalTest()
        {
            var tcpTransport = new TcpTransport("epp.test.cira.ca", 700, new X509Certificate("cert.pfx", "password"), true);

            var service = new Service(tcpTransport);

            //1. SSL connection establishment
            Console.WriteLine("TEST: 1");
            service.Connect();

            //2. EPP <login> command with your ‘a’ account
            Console.WriteLine("TEST: 2");
            var logingCmd = new Login("username", "password");

            var response = service.Execute(logingCmd);

            PrintResponse(response);

            //3. Using the correct EPP call, get the latest CIRA Registrant Agreement
            Console.WriteLine("TEST: 3");
            var agreementCmd = new GetAgreement();

            var getAgreementResponse = service.Execute(agreementCmd);

            var agreementVersion = getAgreementResponse.AgreementVersion;
            var agreementText = getAgreementResponse.Agreement;
            var agreementLanguage = getAgreementResponse.Language;

            PrintResponse(response);
            Console.WriteLine("Agreement Version:{0}", agreementVersion);
            /*
             4. Create a Registrant contact using: 
                -the same ID as your Registrar Number prefixed with the word ‘rant’ (e.g. rant75)
                -CPR category CCT
                -Full postal information, phone number, fax number, and email address
                -Agreed to latest CIRA Registrant Agreement version
             */
            Console.WriteLine("TEST: 4");
            var registrantContact = new Contact("rant" + registrarNumber,
                "Registrant Step Four", "Example Inc.",
                "Toronto", "301 La Fanfan Ave.", "ON", "M5V 3T1", "CA",
                "[email protected]",
                new Telephone { Value = "+1.6478913606", Extension = "333" },
                new Telephone { Value = "+1.6478913607" });


            var registrantContactCmd = new CiraContactCreate(registrantContact);

            registrantContactCmd.CprCategory = CiraCprCategories.CCT;
            registrantContactCmd.AgreementVersion = agreementVersion;
            registrantContactCmd.AggreementValue = "Y";
            registrantContactCmd.Language = "en";
            registrantContactCmd.OriginatingIpAddress = "127.0.0.1";
            registrantContactCmd.CreatedByResellerId = registrarNumber;

            var response1 = service.Execute(registrantContactCmd);

            PrintResponse(response1);

            /*
             5. Create an administrative contact
             -the same ID as your Registrar Number prefixed with the word ‘admin’ (e.g. admin75)
             -using all mandatory elements required for a Canadian administrative contact
             -omit CPR category (he have not agreed to the CIRA agreement)
            */
            Console.WriteLine("TEST: 5");
            var adminContact = new Contact("admin" + registrarNumber,
               "Administrative Step Five", "Example Inc.",
               "Toronto", "301 La Fanfan Ave.", "ON", "M5V 3T1", "CA",
               "[email protected]",
               new Telephone { Value = "+1.6478913606", Extension = "333" },
               new Telephone { Value = "+1.6478913607" });

            var adminContactCmd = new CiraContactCreate(adminContact);

            adminContactCmd.CprCategory = null;
            adminContactCmd.AgreementVersion = null;
            adminContactCmd.AggreementValue = null;
            adminContactCmd.Language = "en";
            adminContactCmd.OriginatingIpAddress = "127.0.0.1";
            adminContactCmd.CreatedByResellerId = registrarNumber;

            const string adminContactId = "admin" + registrarNumber;

            var loginresponse = service.Execute(adminContactCmd);

            PrintResponse(loginresponse);

            //6. Get information for the contact created in operation #4
            Console.WriteLine("TEST: 6");
            var getContactInfo = new ContactInfo(registrantContact.Id);

            var contactInfoResponse = service.Execute(getContactInfo);

            PrintResponse(contactInfoResponse);

            //7. Do a Registrant transfer for domain <registrar number>-3.ca to the Registrant created in operation #4
            Console.WriteLine("TEST: 7");

            //NOTE: registrant transfers are domain updates
//.........这里部分代码省略.........
开发者ID:CodeMakerInc,项目名称:EppLib.NET,代码行数:101,代码来源:Program.cs

示例4: _PreHandleTest

    private void _PreHandleTest()
    {
        Console.WriteLine("PreHandle test:");
        using (Service svc = new Service("PreHandleTest"))
        {
            svc.Start();

            IPEndPoint ep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7788);
            Console.WriteLine("Listened on {0}", ep);

            int connSessionId = svc.Connect(ep);
            Console.WriteLine("Connected to {0}, sessionId: {1}", ep, connSessionId);

            TestPacket data = new TestPacket();
            data.intVal = 10086;
            data.strVal = "Hello World";
            svc.Send(connSessionId, data);

            Console.WriteLine("Press any key to exit PreHandle test...");
            Console.ReadKey();
        }
    }
开发者ID:lailongwei,项目名称:llbc,代码行数:22,代码来源:TestCase_Comm_Service.cs

示例5: ConnectPVIService

        public void ConnectPVIService()
        {
            Log.LogInfo("Connecting PVI Service");

            m_Service = new Service("Service");
            m_Service.Connected += new PviEventHandler(m_Service_Connected);
            m_Service.Disconnected += new PviEventHandler(m_Service_Disconnected);
            m_Service.Error += new PviEventHandler(m_Service_Error);
            m_Service.Connect();
        }
开发者ID:PosauneMaster,项目名称:RecipeMaster_v3,代码行数:10,代码来源:PviService.cs


注:本文中的Service.Connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。