ServerSocket.GetMyIP error

MiniDemonic

Member
Licensed User
Longtime User
I'm getting an error when trying to use ServerSocket.GetMyIP.

If you need something else from the logs then just tell me.
Logs:
B4X:
java.net.SocketException
   at java.net.NetworkInterface.rethrowAsSocketException(NetworkInterface.java:212)
   at java.net.NetworkInterface.readIntFile(NetworkInterface.java:207)
   at java.net.NetworkInterface.getByName(NetworkInterface.java:114)
   at java.net.NetworkInterface.getNetworkInterfacesList(NetworkInterface.java:270)
   at java.net.NetworkInterface.getNetworkInterfaces(NetworkInterface.java:262)


   at anywheresoftware.b4a.objects.SocketWrapper$ServerSocketWrapper.GetMyIP(SocketWrapper.java:175)
   at aa.network.main._tmrip_tick(main.java:378)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
   at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:103)
   at android.os.Handler.handleCallback(Handler.java:605)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4424)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.io.FileNotFoundException: /sys/class/net/usb0/ifindex: open failed: ENOENT (No such file or directory)
   at libcore.io.IoBridge.open(IoBridge.java:406)
   at java.io.RandomAccessFile.<init>(RandomAccessFile.java:118)
   at java.io.RandomAccessFile.<init>(RandomAccessFile.java:150)
   at libcore.io.IoUtils.readFileAsBytes(IoUtils.java:115)
   at libcore.io.IoUtils.readFileAsString(IoUtils.java:109)
   at java.net.NetworkInterface.readIntFile(NetworkInterface.java:200)
   ... 18 more
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
   at libcore.io.Posix.open(Native Method)
   at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
   at libcore.io.IoBridge.open(IoBridge.java:390)
   ... 23 more
java.net.SocketException
 

Kevin

Well-Known Member
Licensed User
Longtime User
I'll be curious what comes up in regards to this. I recently got an email from someone getting this same error with this call. He was using a rooted Droid Bionic running Gummy, which is an ICS ROM.

For now I just trapped the error to avoid a crash, but that doesn't help make a vital function of my app work when I can't get the device's IP address.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
So it would seem that this problem is due to a missing file on various custom ROMs?

Or am I assuming too much? When the guy reported it, I had the impression this wasn't a widespread problem. I wonder how many errors I see in crash reports are from such devices. I don't know why Google doesn't include device and OS info in crash reports.
 
Upvote 0

MiniDemonic

Member
Licensed User
Longtime User
So, is there another way to get the local IP ?
Because if there is then that would be awesome and I could start using that in my apps that use the network.

My current project is a PC monitor, it will show CPU Usage, RAM Usage and running processes, the user will also be able to kill processes from the app, and send keystrokes to the PC.

You could use the app while gaming and put out keybinds on it to access some less used keybinds or whatever you want.

I need to be able to get the device local IP to use it tho, my current work around is to broadcast a ping packet from the PC application and then check the host of the packet that the app pings back. It works but it would be faster to just send the local IP directly.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
So is this problem essentially limited to non-standard "custom" roms?

I suppose in my case I'll just have to offer a short explanation of why the app couldn't retrieve it and allow the user to manually input their own device's IP address.
 
Upvote 0
Top