I have the following typical code in C for Linux to get UDP data:
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, &mysock, sizeof(mysock);
recvfrom(sock, buf, PKTSZ, 0, &client, len);
All of the above code works, but now I need to find out the sender udp port, is there a structure or system call that I can use to get this information when I receive the udp packet?
thanks
linuxNewbie
source
share