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;
}
}