I am building a chrome app and created a UDP socket via the chrome socket api.
Is there a way to retrieve your own IP address without using an external service? What I mean by "own IP address": Both client and server are on the same network. The chrome app needs to answer to a UDP broadcast with it's own local IP address.
There is actually a chrome socket API for exactly that use-case. But unfortunately I only receive the following callback object: Object {paused: false, persistent: false, socketId: 17}
, which misses the localAddress
attribute. It is an (optional) attribute in the SocketInfo
object according to the documentation. This is in essence the code I am running:
chrome.sockets.udp.create({}, function(socketInfo){
chrome.sockets.udp.getInfo(socketInfo.socketId, function (detailedInfo){
ipAddress = detailedInfo.localAddress;
console.debug(detailedInfo); // containts no `localAddress`
});
});
I also do not think that I am missing any manifest-permissions as there are no special permissions described in the API documentation. This is what I use:
"sockets": {
"udp": {
"send": "*",
"bind": "*"
}
}
When I use Python I can achieve that goal as follows:
import socket
ip_address = socket.gethostbyname(socket.gethostname())
Any help would be great!