"Link on the Internet" poorly describes the conditions. Can we be sure that they are both connected to WiFi? Will it be the same wifi or not? Can we use a server for this, or should the design be completely autonomous? This greatly influences the choice of solution.
There are several problems to be solved:
Provide connectivity. Not always two devices connected to the Internet can interact directly. The solution is either limiting conditions (connecting to one WiFi), or using an intermediary in the cloud (for example, GCM, Firebase Storage, Firebase RealtimeDatabase, Google Play services, own server, and a bunch of other options).
Detection. It is necessary that the client device finds the server device. In the case of shared WiFi, you can use Dynamic DNS or IP Broadcast distribution. In a more general case, the use of an intermediary in the cloud.
Actually, the transfer of information. The easiest stage. A lot of possibilities: from direct use of sockets to HTTP.
According to the message scattered keywords. Google and choose.
If your task is related to games, then look at the services provided by Google, for example, Real-time Multiplayer