Ok, I am writing an xbox program that recieves a list of items from a PC application through a UDP socket connection. Each item of the list is sent separately. I have created this thread that constantly listens for the list. The problem is that when the list is longer than around 120 items I get this error: "[XONLINE] udpWarn: [D00212C8] Receive buffer is full (16466 bytes). UDP packet plus 3 data bytes lost." I know that UDP is not very reliable but when the list is say 100 items I have never had it drop a packet.
#define MAXBUFLEN 1000
DWORD __stdcall ListenerThread( void* listen )
{
WSADATA WsaData;
int iResult = WSAStartup( MAKEWORD(2,2), &WsaData );
if( iResult != NO_ERROR )
Debug("Error at WSAStartup");
int sockfd;
struct sockaddr_in my_addr; // my address information
struct sockaddr_in their_addr; // connector's address information
int addr_len, numbytes;
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
Debug("Socket Creation Error");
my_addr.sin_family = AF_INET; // host byte order
my_addr.sin_port = htons(8604); // short, network byte order
my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP
memset(&(my_addr.sin_zero), '\0', 8); // zero the rest of the struct
if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1)
Debug("Bind Error");
addr_len = sizeof(struct sockaddr);
char* xrec = (char*)malloc(MAXBUFLEN);
while(true)
{
if ((numbytes=recvfrom(sockfd, xrec, MAXBUFLEN-1, 0, (struct sockaddr *)&their_addr, &addr_len)) == -1)
Debug("Recieve Error");
xrec[numbytes] = '\0';
}
return 0;
}
#define MAXBUFLEN 1000
DWORD __stdcall ListenerThread( void* listen )
{
WSADATA WsaData;
int iResult = WSAStartup( MAKEWORD(2,2), &WsaData );
if( iResult != NO_ERROR )
Debug("Error at WSAStartup");
int sockfd;
struct sockaddr_in my_addr; // my address information
struct sockaddr_in their_addr; // connector's address information
int addr_len, numbytes;
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
Debug("Socket Creation Error");
my_addr.sin_family = AF_INET; // host byte order
my_addr.sin_port = htons(8604); // short, network byte order
my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP
memset(&(my_addr.sin_zero), '\0', 8); // zero the rest of the struct
if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1)
Debug("Bind Error");
addr_len = sizeof(struct sockaddr);
char* xrec = (char*)malloc(MAXBUFLEN);
while(true)
{
if ((numbytes=recvfrom(sockfd, xrec, MAXBUFLEN-1, 0, (struct sockaddr *)&their_addr, &addr_len)) == -1)
Debug("Recieve Error");
xrec[numbytes] = '\0';
}
return 0;
}