BonCodeAJP13.BonCodeAJP13ServerConnection.BeginConnection C# (CSharp) Method

BeginConnection() public method

start connection using packages stored in instance
public BeginConnection ( ) : void
return void
        public void BeginConnection()
        {
            p_CreateConnection(p_PacketsToSend);
        }

Usage Example

Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //KeyTest();
            //sample setting
            //Console.WriteLine("Sample Setting " + Properties.Settings.Default.SampleSetting);

            //read parameters from console first parameter is server second port
            if (args.Length >= 1)
            {
                myURL = (string)args[0];
            }
            if (args.Length >= 2) {
                myServer = (string)args[1];
            }
            if (args.Length >= 3)
            {
                myPort = (string)args[2];
            }

            string myDNS = myServer; // +":" + myPort;
            ushort iPort = Convert.ToUInt16(myPort);

            //test search
            byte[] sourceBytes = new byte[20] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A };
            byte[] searchBytes = new byte[2] { 0x02, 0x04 };

            int foundPos = ByteSearch(sourceBytes, searchBytes, 0);

            Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));
            Console.WriteLine(BonCodeAJP13Settings.BONCODEAJP13_LOG_DIR);

            ConnectViaString(myDNS, myData);

            //test config
            //Test myTest = new Test();
            //myTest.fHeaderTest();

            //log level
            //Console.WriteLine("Log Level " + BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL);

            //create intance of forward request
            BonCodeAJP13ForwardRequest FR = new BonCodeAJP13ForwardRequest(BonCodeAJP13HTTPMethods.BONCODEAJP13_GET,
                                        "HTTP/1.1",
                                        myURL,
                                        "::1",
                                        "::1", myServer,iPort ,false,1);

            //create cping request
            BonCodeAJP13ForwardRequest FR2 = new BonCodeAJP13ForwardRequest(BonCodeAJP13HTTPMethods.BONCODEAJP13_GET,
                                       "HTTP/1.1",
                                       myURL,
                                       "::1",
                                       "::1", myServer, iPort, false, 1);

            byte[] testBytes = FR.GetDataBytes();  //this returns the contructed databytes

            //byte[] testBytes = FR.WriteServerTestPacket();

            Console.WriteLine("Server: {0} , Port: {1}, URL: {2}", myServer, myPort, myURL);

            //call server request
            BonCodeAJP13ServerConnection sconn = new BonCodeAJP13ServerConnection(FR,true);
            sconn.Server = myServer;
            sconn.Port = System.Convert.ToInt32(myPort);
            sconn.FlushDelegateFunction = PrintFlush;  //this function will do the printing to console

            //run connection
            sconn.BeginConnection();

            //write the response to screen that has not been flushed yet
            foreach (Object oIterate in sconn.ReceivedDataCollection)
            {
                BonCodeAJP13Packet Packet = oIterate as BonCodeAJP13Packet; //only objects derived from this class should be in the collection
                Console.WriteLine(Packet.GetDataString());
            }
            Console.WriteLine("Last Size:" + sconn.ReceivedDataCollection.Count);

            //call connect function
            //ConnectViaString(myDNS, myData);
            //Connect(myDNS, testBytes);

            int a = 2;
            a++;
        }
All Usage Examples Of BonCodeAJP13.BonCodeAJP13ServerConnection::BeginConnection