title: How do I get sender's UDP port in C?
body: <p>I have the following typical code in C under Linux to get UDP data:</p>
  
  <pre><code>sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
  mysock.sin_family = AF_INET;
  mysock.sin_addr.s_addr = INADDR_ANY;
  mysock.sin_port = my_port;
  bind(sock, &amp;mysock, sizeof(mysock);
  recvfrom(sock, buf, PKTSZ, 0, &amp;client, len);
  </code></pre>
  
  <p>All the above code works, but now I have a need to find out the sender's udp port, is there a structure or system call I can use to retrieve such info when I receive a udp packet ?</p>
  
  <p>thanks</p>