GetMyWifiIP error

Rusty

Well-Known Member
Licensed User
Longtime User
The below code has been working for a while and now it fails with:
B4X:
GetMyIP error: (ErrnoException) libcore.io.ErrnoException: bind failed: EACCES (Permission denied)
The code is as follows:
B4X:
Sub GetMyIP As String
    Dim IP As String = ""
    Try
        Dim Server As ServerSocket
        Server.Initialize(TCP.Port, "MyIP")
        IP = Server.GetMyWifiIP
        'IP = Server.GetMyIP 
        Server.Close
    Catch
        Log("GetMyIP error: " & LastException)
    End Try
    Return IP
End Sub
I recently upgraded to 2.71. I don't know if this is part of the issue, but would appreciate any advice.
Thanks,
Rusty
 

Rusty

Well-Known Member
Licensed User
Longtime User
B4X:
GC_CONCURRENT freed 2043K, 12% free 16931K/19079K, paused 2ms+3ms
main_getmyip (B4A line: 4810)
Server.Initialize(TCP.Port, "MyIP")
java.net.BindException: bind failed: EACCES (Permission denied)
    at libcore.io.IoBridge.bind(IoBridge.java:89)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:150)
    at java.net.ServerSocket.<init>(ServerSocket.java:100)
    at java.net.ServerSocket.<init>(ServerSocket.java:69)
    at anywheresoftware.b4a.objects.SocketWrapper$ServerSocketWrapper.Initialize(SocketWrapper.java:191)
    at talkingsurvey.b4a.survey.main._getmyip(main.java:7848)
    at talkingsurvey.b4a.survey.main._udptimer_tick(main.java:13911)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
    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:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: bind failed: EACCES (Permission denied)
    at libcore.io.Posix.bind(Native Method)
    at libcore.io.ForwardingOs.bind(ForwardingOs.java:39)
    at libcore.io.IoBridge.bind(IoBridge.java:87)
    ... 19 more
java.net.BindException: bind failed: EACCES (Permission denied)
Thanks Erel.
No, I haven't set the Manifest to read only...should I?
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
No, I haven't set the Manifest to read only...should I?
No.

The problem is that you are initializing ServerSocket with a restricted port number. I guess that you only use ServerSocket to call GetMyWifiIP. If this is correct then you should not initialize ServerSocket at all. You can add an 'ignore comment to ignore that warning.
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Yes, I only want to acquire the IP address.
I use it in my UDP broadcast data gram to establish a connection with a host. It is embedded within my UDP message.
Is there another/better way to merely acquire the IP Address of the tablet?
Thanks,
Rusty
BTW, removing the initialization does cause it to get the IP address successfully.
Thanks again, Erel
 
Last edited:
Upvote 0
Top