11-21-2013 03:27 PM
I am using the visa test panel in NI MAX ver 5.4.0 and I connect to a CVI application I currently have a server socket up and running. My server accepts the connection form the visa test panel ok, and when I write from the visa my application sees it immediately. Then I try to read and the visa will timeout, at which point the visa displays what I sent in the 'send' command. I cannot determine why the visa writes to my application ok but the send is not received until the timeout occurs in the visa tool. In my application I am doing a simple 'send' on a valid socket. I am not sure why, but if anyone has any answers I would appreciate it. Here is a snippet of my code in my main:
char sendbuf[64];
strcpy (sendbuf, "ACK\n");
/* Initialize WINSOCK before any socket calls are made */
iResult = WSAStartup(MAKEWORD(2,2), &WSAData);
if ( iResult != 0 )
return SOCKET_ERROR;
if ((ServerSock = SockOpenServer(SERVER_PORT_NUMBER_TCP)) == SOCKET_ERROR)
return SOCKET_ERROR;
/* By now the socket should be successfully bound. */
/* Wait for clients to connect. As each client connects, */
AcceptedSock = SockWaitForAccept(ServerSock);
/* Indicate the socket has been initialized and a client has been accepted */
if (AcceptedSock > 0)
isServerInitComplete = TRUE;
else if (AcceptedSock == SOCKET_ERROR)
runRDPServer = FALSE;
while (runRDPServer)
{
BytesReceived = recv(AcceptedSock, ptrCh, BytesToRead, 0);
if (BytesReceived > 0)
{
/* for now just send back an ACK to ackknowledge the receipt of data */
if (strncmp(ptrCh, "*IDN", 4) == 0)
BytesSent = send(AcceptedSock, sendbuf, (int)strlen(sendbuf), 0 );
if (strncmp(ptrCh, "*ESE", 4) == 0)
runRDPServer = FALSE;
}
}
11-22-2013 02:59 PM
Hello,
Make sure that you are sending the right termination character or you might be sending characters too fast. Here is an article that explains this further:
http://digital.ni.com/public.nsf/allkb/171D2D70CFB66E74862571390062D12B?OpenDocument
Thanks!
11-25-2013 11:50 AM
Stephanie, I did go look at the link you provided this morning. That particular paper seem to deal with serial connections. The app I have is for TCP/IP and that's where my problem is. I did find out today, that when talking to my app using a LabView app for TCP there is no timeout in the receipt of data in the LabView TCP app, where as the Visa connection timeouts but still reads the buffer after the timeout occurs. So there is something in that Visa connection to my app, which is a server in 'C' creating the socket. We are currently going to continue with an interface with a LabView TCP connection to my app. Thanks for your input.