Question

I have a PBX machine which i need to communicate using Ip and Port number along with the username and password.At present i am able to connect to the machine by using the ip address and port number.But On sending the Username and password to the machine for authentication i am not getting the required data out from the machine into the text file instead i am getting the username and password send to the machine in format like this into the text file.

Here is my code in c#..

        ipaddress = "";
        int port = int.Parse("");
        textfileSaveLocation = "";

        byte[] data = new byte[1024];
        string stringData;
        //string input;

            IPAddress ipadd = IPAddress.Parse(ipaddress);
            IPEndPoint ipend = new IPEndPoint(ipadd,port);
            Socket sock = new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);
            sock.NoDelay = false;
            try
            {
                sock.Connect(ipend);
                textBox4.AppendText("Connected to host" + "\r\n");
            }
            catch (Exception dfg)
            {
                textBox4.AppendText("Problem connecting to host" + "\r\n");
                textBox4.AppendText(dfg.ToString ()+"\r\n");
                return;
            }
            try
            {
                int recv = sock.Receive(data);
                stringData = Encoding.ASCII.GetString(data, 0, recv);
                textBox4.AppendText(stringData + "\r\n");
                while (true)
                {
                    Byte[] bBuf;
                    string buf;


                    Application.DoEvents();

                    buf = String.Format("{0}/{1}", "SMDR", "PCCSMDR");
                    bBuf = Encoding.ASCII.GetBytes(buf);
                    sock.Send(bBuf);     


                    data = new byte[1024];
                    recv = sock.Receive(data);
                    stringData = Encoding.ASCII.GetString(data, 0, recv);
                    textBox4.AppendText(stringData + "\r\n");
                    string df = "";
                     try

        }

I am trying to figure out the mistake from two days but not able to find out..Just help me out where i am going wrong..

Était-ce utile?

La solution

The specification mentions:

You can activate the "ASCII Data Query" plugin and specify the login/password request as: SMDR#0D#0APCCSMDR#0D#0A

So both the username and password will need to be carriage return-terminated:

buf = String.Format("{0}\r\n{1}\r\n", "SMDR", "PCCSMDR");

Autres conseils

This is a special format string that the specified software uses to send login and passowrd.

The command string will be interpreted as:

SMDR<CR><LF>PCCSMDR<CR><LF>

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top