Most chat applications can run both server and client simultaneously, well in my case all I need is to connect all devices that uses my app to share data( gson object), in official documentation, I found direct WiFi connection (p2p) which doesn't work if the other device is not on local network, and socket ( server client separated ), which work only one way one device for sending and the other for receiving.
So does anyone have an example of connecting two or more devices trough internet by running both server and client socket in the same time.