I need to create a program that will communicate with other programs on the same computer via UDP sockets. It will read commands from stdin, and some of this commands will make it to send/recieve packets without halting execution. I've read some information out there, but since I'm not familiar with socket programming and need to get this done quickly, I have the following questions:
Also a code sample of the setup of such socket would be welcome, as well as an example of sending/recieving character strings.
Call bind()
specifying port 0. That will allow the OS to pick an unused port. You can then use getsockname()
to retreive the chosen port.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With