Thanh Dong
Thanh Dong

Reputation: 3

Can an Androip app on Chromebook create a socket TCP server, listen connections and connect to other socket server on LAN network?

I have an android app that creates a socket TCP server to listen connections from a windows app. And sometimes it connects to the socket server on windows app.

It works properly on android devices. It can also receive broadcast packets. However, it does not work when I install on Chromebook.

It cannot listen any connection, receive any packets or connect to the server on windows app.

Could anyone help me explain why and guide me some solutions to fix?

Best regards.

Upvotes: 0

Views: 572

Answers (1)

Thanh Dong
Thanh Dong

Reputation: 3

I understood about network in Chromebook and found Network Service Discovery as the solution here https://developer.android.com/topic/arc

Check for networking requirements

Chromebooks run the entire Android OS in a container, similar to Docker or LXC. This means that Android will not have direct access to the system's LAN interface. Instead, IPv4 traffic will pass through an internal layer of network address translation (NAT), and IPv6 unicast traffic will be routed through an extra hop. Outbound unicast connections from an Android app to the internet should mostly work as-is; but in general, inbound connections are blocked. Multicast or broadcast packets from Android will not be forwarded to the LAN through the firewall.

As a special exception to the multicast restriction, Chrome OS runs a service that forwards mDNS traffic between Android and the LAN interface, so the standard Network Service Discovery APIs are the recommended way to discover other devices on the LAN segment. After finding a device on the LAN, an Android app can use standard TCP or UDP unicast sockets to communicate with it.

IPv4 connections originating from Android will use the Chrome OS host's IPv4 address. Internally, the Android app will see a private IPv4 address assigned to the network interface. IPv6 connections originating from Android will use a different address from the Chrome OS host, as the Android container will have a dedicated public IPv6 address.

Upvotes: 0

Related Questions