LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ConnectToTCPServer

Hi,

 

Could someone help?

 

Why am I getting a library function error

 

if (ConnectToTCPServer (&g_hconversation, portNum, serverHostName, clientTCP, NULL, 5000) <0

{

     return 0;

 

portNum is 5000

serverHostName is 192.168.2.3  and I can ping it.

 

my clientTCP function is:

 

 

int clientTCP (unsigned handle, int event, int error, void *callbackData)
{
    char receiveBuf[256] = {0};
    int  dataSize         = sizeof(receiveBuf)-1;
 char lineBuf[130];

    switch (event)
        {
        case TCP_DATAREADY:
#if 0
            if ((dataSize = ClientTCPRead (g_hconversation, receiveBuf, dataSize, 1000)) < 0)
   {
    return -1;
   }
   printf("TCP_DATAREADY received: %s\n",receiveBuf);
#endif   
            break;

        case TCP_DISCONNECT:
   if(error)
   {
    sprintf(lineBuf,"TCP_DISCONNECT received due to error= %d\n", error);
    PRINT_DBG(lineBuf);
       g_hconversation = INVALID_TCP_HANDLE;
   }
   else
    PRINT_DBG("TCP_DISCONNECT received from TcpServer\n");
            break;
        default:
         printf("default received\n");
         break;
    }
    return 0;
}

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

Hello agyna,

which error are you receiving and where? Does it happens every time you run the code?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(3,327 Views)

Sorry, looks like the problem is resolved.

Thanks.

0 Kudos
Message 3 of 3
(3,324 Views)