When the sendto() is used to send the data through udp socket, the destination address is specified in the sendtocall but where do we specify the source address. The destination address(server) I used is 5001::1, In the server log I saw a message saying the request came from 5001::2 port 12345. What if I want to change the source address to 5001::20. I’m sure this is a dumb question. But please clarify. thanks for your time.
When the sendto() is used to send the data through udp socket, the destination
Share
The source address is the address of the computer sending the packet. This is filled in automatically by the OS so that when the other computer replies, the reply packet goes to the correct place. If you want to change the source address, change the address assigned to your network interface.