socket programming using UDP connection

I want to send packets through single socket() but using two different port numbers in UDP. Anybody give some idea on this.

Thanks in advance.:slight_smile:

Using, as it originating from two different ports? Internet protocol doesn't work that way; one socket, one port. Nothing stops you from opening two ports of course.

1 Like

Do you mean you want to control the source and destination ports? If so, you can bind() to a local port and then either sendto() the remote port or connect() to it and and write()/send().