Hi Syed,
Have you tested by adding the FLAG_ABORT_CONNECTION flag?
The value for it is:
#define FLAG_ABORT_CONNECTION (0x0010)
I do it in this code and it works all the time:
while(TRUE)
{
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock == RTCS_SOCKET_ERROR)
{
printf("\nError, socket create failed");
return;
}
memset((char *) &local_sin, 0, sizeof(local_sin));
local_sin.sin_family = AF_INET;
local_sin.sin_port = SERVER_BROADCAST_PORT;
local_sin.sin_addr.s_addr = INADDR_ANY;
result = bind(sock, &local_sin, sizeof (sockaddr_in));
if (result != RTCS_OK)
{
printf("\nError, bind() failed with error code %lx", result);
}
memset((char *) &remote_sin, 0, sizeof(sockaddr_in));
remote_sin.sin_family = AF_INET;
remote_sin.sin_port = SERVER_BROADCAST_PORT;
remote_sin.sin_addr.s_addr = INADDR_BROADCAST;
ipcfg_get_ip(BSP_DEFAULT_ENET_DEVICE, &MyIP_data);
//printf("\nIP Address : %d.%d.%d.%d\n",IPBYTES(MyIP_data.ip));
snprintf(myBuffer, 50, "ServerForAndroid %x\n", (uint_32)MyIP_data.ip);
printf("%s",myBuffer);
//count = sendto(sock, my_buffer, 11, 0, &remote_sin, sizeof(sockaddr_in));
count = sendto(sock, myBuffer, sizeof (myBuffer), 0, &remote_sin, sizeof(sockaddr_in));
if (count == RTCS_ERROR)
{
printf("\nsendto() failed with error %lx\n", RTCS_geterror(sock));
}
else
{
printf("\nSent %ld bytes of data.", count);
}
shutdown(sock, FLAG_ABORT_CONNECTION);
_time_delay(1000);
}
I hope this helps you.
-Garabo