This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM642 and NDK question

 

I am using DM642 and NDK.

I write the code for receiving the fixed port UDP packet, the code is belowing:

fdOpenSession( TaskSelf() );
s= socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
bzero( &localAddr, sizeof(struct sockaddr));
localAddr.sin_family     = AF_INET;
localAddr.sin_len        = sizeof( localAddr );
localAddr.sin_addr.s_addr= 0x6400A8C0;
localAddr.sin_port       = htons(9001);
bind( s, (PSA) &localAddr, sizeof(localAddr) )
 while(1)
{
     fromlen = sizeof(localAddr);
     retval = (int)recvfrom( s, pBuf, MAXPACKET, 0, &localAddr, &fromlen );
}
I can receive the UDP packet which the destination port is 9001.
Then If I want to receive the UDP packets with any port number,how can I write the code?
Please help me,
Thank you!