Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can lidgren-network library connect directly peer to peer given both IP addresses

Tags:

c#

p2p

lidgren

I am using lidgen-network library 3 to try and create a peer to peer connection. I am new to network programming which is why i'm using this library.

Using the DiscoverKnownPeer() function i have been able to connect within my network. What i have read online is that i need to do a NAT punchthrough which requires a running server that is outside the router. I am hoping for a solution that doesnt require this extra server.

If i can store both ip addesses on a web server, and get create a web service to send the ip's to each respective client through XML, would I be able to create a peer to peer connection?

Thank you in advance.

like image 999
arren the imposter Avatar asked Sep 24 '10 04:09

arren the imposter


1 Answers

No, you won't be able to establish a connection through NAT without a rendezvous server

NAT stands in your way because even if you know the IP address, that only gets you as far as the router. The router receives a request coming from the internet, and doesn't know which internal IP to send it to, so it throws it away.

NAT punchthrough works by making both peers send outgoing request to each other, the router then "knows" that packets directed at its public IP on the given port should go to the given computer.

So, you need to connect both computers to an external server not behind NAT, and then use that external server to coordinate connecting the two NAT obscured peers together (this is the peer introduction thing that Lidgren has built in).

like image 193
Martin Avatar answered Nov 08 '22 14:11

Martin