Question sending data between two Smartphones without sending data through Server

__Rob__

Junior Member
Jan 14, 2022
2
0
6
I try to programm a Mobile Messenger (C++, Qt) where the Server only sends the current IP address of Phone A to Phone B and vice versa and the data is send directly between these two devices with the goal to minimize the needed calculationpower of the server.

I try to understand if that is possible:
Client A has a connection to Server S and Client B has a connection to S as well. If S sends the IP and Port of A to B, can B send something to A without creating a new connection through using the IP of A and the Port which A is already listening to?

Has someone a better idea how to solve this or is this idea in general impossible i.e. you always have to send data between two Smartphones through a server.
 

__Rob__

Junior Member
Jan 14, 2022
2
0
6

It's just impossible if you need to connect devices remotely in different locations.

==

You can establish a VPN and give each device a virtual private IP and let them communicate, but is that what you want?

Thank you for the answer.

I think with VPN I would again need a VPN Server where the traffic between the smartphones is going through or is it possible to create a VPN between two Smartphones without the Server?

I try to find out, if it is possible to use the Server only for transmitting the IP Address from Smartphone A to Smarphone B and vice versa and then create a Peer-to-Peer connection between these two Smartphones. Logically it should be possible because in this situation A and B know their IP-Addresses. I only wonder if there is a protocoll above IP which would support a direct connection like that without having problems like pushforwarding.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,100
126
First of all, I'm not a programmer. I'm a PC network guy with some programming background. And I really have no idea about smartphone's networking infrastructure & protocols. I guess it's totally different from PC environment.

Take a look of Zeortier VPN video below, and research its source code , see if you can learn something from it.


And I think you absolutely need to study how to write Android APP if that's the platform you are targeting. Like I said, it could be totally different from PC environment.

https://developer.android.com/
 
Last edited:
  • Like
Reactions: killster1

Red Squirrel

No Lifer
May 24, 2003
67,204
12,030
126
www.anyf.ca
The biggest challenge is you would require port forwards for each phone when they are on wifi, or at least whichever one is acting as server, if the protocol you design works that way. This is doable but it's just an extra step that users need to be aware of, and in some settings may not be able to (ex: corporate networks, public wifi etc). So I would lean towards still having a central server. If that is not something you want to host I would just make it available so whoever wants to use the chat can setup their own server. In fact I wish more cloud services worked this way, just let people host their own server.