B4J Question B4J Remte Conrol IP Address return

BPak

Active Member
Licensed User
Longtime User
Running example supplied and get IP as fe0:0:0:0:8cbb:12bf:555b;a6a8%wlano
This is not same as expected.
How to get correct IP?
 

Daestrum

Expert
Licensed User
Longtime User
Not sure what you mean by correct IP - that figure is an IPv6 address for what looks like a wireless lan adaptor (wlano is probably wlan0 meaning wireless adaptor #0)
 
Last edited:
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

not sure what example you have been using, but indeed this is an inet6 address.

Example: If you run on the Raspberry Pi the command $ifconfig, then you can check for the wlan adapter 0
Output like

...
wlan0 Link encap:Ethernet HWaddr 74:da:38:04:ef:41
inet addr:192.168.0.39 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::76da:38ff:fe04:ef41/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:253752 errors:0 dropped:74 overruns:0 frame:0
TX packets:12089 errors:0 dropped:1 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:55444118 (52.8 MiB) TX bytes:3268764 (3.1 MiB)
...
 
Upvote 0

BPak

Active Member
Licensed User
Longtime User
Running the Control Desktop from Android app.ControlDesktop - under Tutorials. The code supplied for B4j puts up a notification panel with the IP Address.
Yes it appears to be for IP6 and not IP4. I found solution for Android with JavaObject but the same function InitializeContext is not available in B4J.
Maybe someone knows how to do this in B4J?
My computer is a Mac OSX with win 7 installed on Boot camp and has WiFi and Bluetooth.
 
Last edited:
Upvote 0

BPak

Active Member
Licensed User
Longtime User
Hi,

not sure what example you have been using, but indeed this is an inet6 address.

Example: If you run on the Raspberry Pi the command $ifconfig, then you can check for the wlan adapter 0
Output like

...
wlan0 Link encap:Ethernet HWaddr 74:da:38:04:ef:41
inet addr:192.168.0.39 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::76da:38ff:fe04:ef41/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:253752 errors:0 dropped:74 overruns:0 frame:0
TX packets:12089 errors:0 dropped:1 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:55444118 (52.8 MiB) TX bytes:3268764 (3.1 MiB)
...
Do no have Raspberry pi.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
If you want to use IPv4 addresses try this (found on stack overflow)
By using this _JAVA_OPTIONS=-Djava.net.preferIPv4Stack=true environment variable. (read about _JAVA_OPTIONS here)

Just run this command on Windows cmd:
setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true
 
Upvote 0

BPak

Active Member
Licensed User
Longtime User
[QUOnetwork connectiol, post: 385358, member: 1"]ServerSocket.GetMyIp will return the ip4 address if such is available. So the preferIPv4Stack is not required.

Is the Mac computer connected to a network?[/QUOTE]
ServerSocket.GetMyIp will return the ip4 address if such is available. So the preferIPv4Stack is not required.

Is the Mac computer connected to a network?
No network is connected to this computer. And computer is not connected to any network.
Using the preferipv4 now causes a red message to appear in all b4j progs in the Log message that is.
Picked up _JAVA_OPTIONS: -Djava.net.preferIPV4Stack=true.
 
Upvote 0

BPak

Active Member
Licensed User
Longtime User
QUOTE="Erel, post: 385379, member: 1"]The remote desktop example requires a network to work. The commands are sent over a TCP or UDP connections.[/QUOTE]
Ok. Thanks.
 
Upvote 0

BPak

Active Member
Licensed User
Longtime User
If you want to use IPv4 addresses try this (found on stack overflow)
Hi Daestrum.

When I run B4J I now get a red message in the log window which says:

Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true

I guess it does no harm to my progs.

Do you know of a way to undo the setting I made?

Maybe it is in some INI file?
Thank you.

Found: ENVIRONMENT VARIABLE
 
Last edited:
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I would guess you simply run the command again but with the setting =false
 
Upvote 0
Top