Android Question AsyncStreamsObject - Send and receive objects over the network

dibesw

Active Member
Licensed User
Sorry the request is:
I have tested AsyncStreamObject for send and receive text and image from device to another device;
If the device are in local network, this works well.
but if the device are in internet connection (not in local network) this not longer works.
is it possible to do something now?
 

derez

Expert
Licensed User
Is there a possibility for device to device in internet connection (without lan)?
Yes, but then both need to have a fix address like when using duckdns or similar service.
 

dibesw

Active Member
Licensed User
If I use this code:
B4X:
Dim hc As HttpClient
hc.Initialize("hc")
req.InitializeGet("http://ipecho.net/plain")
hc.Execute(req, 1)

Sub hc_ResponseSuccess(Response As HttpResponse, TaskId As Int)
    ipall.Text = "Indirizzo IP: " & Response.GetString("UTF8")
End Sub

Sub hc_ResponseError(Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
    Msgbox("Errore IP - "  & Response.GetString("UTF8"), "")
End Sub
Then I get a public IP address; can I use this IP address?
It works if I use local address but not works if I use this public IP. Why?
(I use AsyncStreams)
 

DonManfred

Expert
Licensed User
Then I get a public IP address; can I use this IP address?
Yes. This is the ip from the device calling this url.
If you have devices A and B and A is calling this url. A knows the ip of itself now.
B call the same url, get another IP. B is knowing the ip of itself now.

But how do you realize that A know the IP of B and B knows the IP of A?
 

dibesw

Active Member
Licensed User
This IP can put into a web server, but this IP however it does not work.
It works only local IP.
 
Top