LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

callback passed to ConnectToTCPServer is not being called...

Hello,

Here's my code:

static int CVICALLBACK tcpCB (unsigned handle, int event, int error, void *callbackData);

iRet = ConnectToTCPServer (&gModem.TCPHandle, gModem.TCPPort,
            gModem.Number, tcpCB, NULL, 5000);

The tcpCB is never getting called.

I tried slightly different decrares for the callback function - nothing.

Help is appreciated.

0 Kudos
Message 1 of 5
(3,702 Views)
Are you getting an error return from ConnectToTCPServer() ? Your call looks OK in principle but there may be a typo somewhere in defining port numbers, server names or whatever. Is the Server you are trying to connect to on the same PC or across a network - maybe a firewall is getting in the way?
 
JR
0 Kudos
Message 2 of 5
(3,700 Views)
The device I'm connecting to is on a small network segment,
no proxies or gateways or anything.
I can connect, I can write and read just fine, no errors.
0 Kudos
Message 3 of 5
(3,699 Views)

So I'm guessing that you are using ClientTCPRead() to retrieve the data in some kind of timed/tight loop? This might be having an effect on the callback structure - in my programs I only call ClientTCPRead() from within the callback itself, when the TCP_DATAREADY event is received.  IIRC, you will only get callbacks triggered if there is a ProcessSystemEvents() or similar within the program - if you are running in a separate thread this could be the reason no callbacks are being generated. Maybe someone from NI with inside knowlegde of the TCP callback structure can advise?

JR

Message 4 of 5
(3,690 Views)
ProcessSystemEvents() did it, it started firing the callback.
Strange thing is, after I commented out the
ProcessSystemEvents()
statement, the callback is still working!
Mystery... But it seems to work now, so thank you very much!

Gene
0 Kudos
Message 5 of 5
(3,687 Views)