Click here to Skip to main content
16,004,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Through a Windows mobile 6.5 device using c#.net 2008 smartphone application,
I need to dial NAC and pass a ISO 8583 standard message string through the connection & to get the response back.
I don't have any idea to do this. Tried several ways none of them succeed.

1. manually dial the number using microsoft.Telephony reference. after connecting with the modem, tried to pass the message using TCPClient object by calling the IP & port.
2. manually dial the number using microsoft.Telephony reference. after connecting with the modem, tried to pass the message using serialPort object by assigning COM8.

But none of the above methods succeed.

3. Then I got their apn activated sim. Now I can connect to the apn using the sim and then tried to pass the message using TCPClient object by setting the IP & port.
Then I can pass the message without an error. but the response is not coming. I do not know how that NAC is functioning. According to them, NAC is taking the incoming data and direct them to the network switch.

If we consider the 3rd option,

- Is there a way to check whether my data string is accepting from the NAC or rejecting or is not going to the NAC?
- Is there any other way to connect and send data from a windows mobile device to the NAC ?

If anyone have a solution for this or have experience on ISO 8583 standards please help me.

Below given the code for 3rd option,

C#
private BIM_ISO8583.PDA.ISO8583 iso8583 = new BIM_ISO8583.PDA.ISO8583();

public string[] Start(string DataStream, string MTI, out string ResponseData)
{
    string connectIP = "192.186.1.10";
    string connectPort = "7979";
    string[] byteResponsetemp = new string[0];

    ResponseData = string.Empty;

    String server = connectIP;

    // Convert input String to bytes
    byte[] byteBuffer = Encoding.UTF8.GetBytes(DataStream);

    // Use port argument if supplied, otherwise default to 8080
    int servPort = Int32.Parse(connectPort);//7 ;

    TcpClient client = null;
    NetworkStream netStream = null;

    try
    {
        // Create socket that is connected to server on specified port
        client = new TcpClient(server, servPort);

        //MessageBox.Show("Connected to server... sending echo string");
        netStream = client.GetStream();

        // Send the encoded string to the server
        netStream.Write(byteBuffer, 0, byteBuffer.Length);

        int totalBytesRcvd = 0; // Total bytes received so far
        int bytesRcvd = 0; // Bytes received in last read

        // Receive the same string back from the server

        while (totalBytesRcvd < byteBuffer.Length)
        {
            if ((bytesRcvd = netStream.Read(byteBuffer, totalBytesRcvd, byteBuffer.Length - totalBytesRcvd)) == 0)
            {
                ResponseData = Encoding.ASCII.GetString(byteBuffer, 0, byteBuffer.Length);

                MessageBox.Show("Connection closed prematurely." + ResponseData);
                break;
            }
            totalBytesRcvd += bytesRcvd;
        }

        ResponseData = Encoding.ASCII.GetString(byteBuffer, 0, totalBytesRcvd);
        if (ResponseData.Length > 0)
        {
            byteResponsetemp = iso8583.Parse(ResponseData);
        }
    }
    catch (Exception e)
    {
        MessageBox.Show("Start:" + e.Message);
    }
    finally
    {
        netStream.Close();
        netStream.Dispose();
        client.Close();
    }
    return byteResponsetemp;
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900