Solved Is it necessary to give IP address while opening a socket?
-
My Program communicates with a device over UDP protocol. My maschine has multiple IP addresses, WiFi (local) and LAN (internet). The connection from my maschine to the device takes place over WiFi, The device is connected with a cable to WiFi router. I am opening a socket with WiFi IP address and port number. Is is absolutely necessary to give the correct IP address? What happens if I only give port number? Can the Operation System find the correct IP address for that communication and assign a socket WiFi IP:port?
-
You have to provide the IP of the device you want to connect to. It doesn't matter how the target is connected to the network you need its IP.
-
@jsulm Ok, it is clear that the Destination IP should be provided, I meant my IP address, source IP. Should it also be provided or can the OS find appropriate Source IP, since I have multiple IPs?
-
You don't need to provide the source IP.
-
Here is an example: http://doc.qt.io/qt-5/qudpsocket.html#details
-
@jsulm Ok thanks.