From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ConnectToTCPServerEx

Hello,

 

We have some issues for using ConnectToTCPServerEx function.

Issue : When I called "ConnectToTCPServerEx function", sometime it looks ignoring to call the callback function"ReadCallback". Could it happen if I call ConnectToTCPServerEx function several times in a few minutes?

 

I mean I did connect, disconnect, conect, disconnect , connect and disconnect and etc. I have set the communication handle to 0(zeron) when the case is TCP_DISCONNECT.

Do you have any known issues or any advice when we call  ConnectToTCPServerEx while keep changing connections?

 

Thank you so much,

momo

 

 

In the "ReadData":

 

ReadData() {

...

ConnectToTCPServerEx (&hGrRead,ReadPort, GRipAddress, ReadCallback, 0, 0, TCP_ANY_LOCAL_PORT)

...

}

 

In the "ReadCallback":

 

ReadCallback() {

...

  case TCP_DATAREADY:

            if((error = ClientTCPRead (handle,header,28, 0)) < 1){
            return -1;
   }

 

......

 

  case TCP_DISCONNECT:
   if (handle > 0)
    handle =0;
    break;

 

}

 

 

 

 

 

 

0 Kudos
Message 1 of 3
(4,338 Views)

 

Hello,

 

It looked like my simulator which has heavily SNMP function has issues.

If I gave some delay before calling the callback function(includes ConnectToTCPServerEx), it is working.

 

Does anybody have the similar issue or experience?

 

Thank you,

 

Insuk


@momo2013 wrote:

Hello,

 

We have some issues for using ConnectToTCPServerEx function.

Issue : When I called "ConnectToTCPServerEx function", sometime it looks ignoring to call the callback function"ReadCallback". Could it happen if I call ConnectToTCPServerEx function several times in a few minutes?

 

I mean I did connect, disconnect, conect, disconnect , connect and disconnect and etc. I have set the communication handle to 0(zeron) when the case is TCP_DISCONNECT.

Do you have any known issues or any advice when we call  ConnectToTCPServerEx while keep changing connections?

 

Thank you so much,

momo

 

 

In the "ReadData":

 

ReadData() {

...

ConnectToTCPServerEx (&hGrRead,ReadPort, GRipAddress, ReadCallback, 0, 0, TCP_ANY_LOCAL_PORT)

...

}

 

In the "ReadCallback":

 

ReadCallback() {

...

  case TCP_DATAREADY:

            if((error = ClientTCPRead (handle,header,28, 0)) < 1){
            return -1;
   }

 

......

 

  case TCP_DISCONNECT:
   if (handle > 0)
    handle =0;
    break;

 

}

 

 

 

 

 

 



 

0 Kudos
Message 2 of 3
(4,311 Views)

In what way are you calling the callback? Usually a callback will run when an event occurs, so they don't need to be directly called. When you say the callback is ignored, are you missing complete messages (data or packages) or only parts of messages from the TCPServer? CVI actually ships with a TCP/IP example that you could look at. On Windows 7, it is located at: C:\Users\Public\Documents\National Instruments\CVI2013\samples\tcp. Unfortunately, I'm not familiar with SNMP, so I don't know if there is a delay associated with communication.

Taylor B.
National Instruments
0 Kudos
Message 3 of 3
(4,301 Views)