Hi David,
Here is the code I use for the receiving the data. I reformatted it a little bit for readability, but it's the same operations. In the code, I first check if there's something on the network before I do the recvfrom, but even without this code (which is useless in this simplified version), the problem remains.
int nSocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP); struct sockaddr_in stAddr; memset (&stAddr, '\0', sizeof (stAddr)); stAddr.sin_family = AF_INET; stAddr.sin_addr.s_addr = htonl (INADDR_ANY); stAddr.sin_port = htons (nPort); bind (nSocket, (struct sockaddr *)&stAddr, sizeof (stAddr); while (1) { fd_set fdReadMap; FD_ZERO (&fdReadMap); // Clear all file descriptors in set FD_SET (nSocket, &fdReadMap); // Set a filedescriptor in a set // select : Monitor read, write, and exception status rval = select (nSocket + 1, &fdReadMap, (fd_set *) NULL, (fd_set *) NULL, pPollTime); if (rval <= 0) continue; else if (FD_ISSET (nSocket, &fdReadMap)) { struct sockaddr_in stLastPacketFrom; rval = recvfrom (nSocket, pPacket, nPacketSize, 0, (struct sockaddr *)&stLastPacketFrom, &nFromLength); WSACleanup (); }
To answer your question, I normally use a structure to send the data, not a simple string. The problem is there in both version. The string is there only because I wanted to remove as many things as possible to identify the source of the problem.
Antheus, it's a good information you gave me. Unfortunately, it does the same thing when I fix it using a int.