Android Question How to make p2p connection with B4X?

bjfhs

Active Member
Licensed User
I need transfer video between two device, I have a service with static IP, and the two device connect the internet with router (nat),but not in the same local intranet.
I try to make P2P (UDP) connection,but failed.
1.Client A connect with server ,and tell the server its IP and Port
2. Client B connect with server ,and tell the server its IP and Port
3. Server tell B's IP and Port to A , and A's IP and Port to B
4, Client A send message to B with the B's IP and Port , Client B send message to A with the A's IP and Port
 

DonManfred

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

KZero

Active Member
Licensed User
Longtime User
I need transfer video between two device, I have a service with static IP, and the two device connect the internet with router (nat),but not in the same local intranet.
I try to make P2P (UDP) connection,but failed.
1.Client A connect with server ,and tell the server its IP and Port
2. Client B connect with server ,and tell the server its IP and Port
3. Server tell B's IP and Port to A , and A's IP and Port to B
4, Client A send message to B with the B's IP and Port , Client B send message to A with the A's IP and Port
Theoretically, you can with B4X

but this scenario will work with less than 1% of routers
there are many NAT types and many NAT traversal mechanisms, it's really complicated and even big apps like Skype can't make the p2p connection in every time

if your is to make a video call then use a SIP service Abto VOIP SIP
and if you want to know more about NAT traversal mechanisms read about STUN , TURN and ICE
 
Upvote 0
Top