开发者

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

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 开发者_C百科the ip's to each respective client through XML, would I be able to create a peer to peer connection?

Thank you in advance.


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).


I know this is old but...

You didn't specify that using the DiscoverKnownPeer() was necessary in your setup. If it isn't then you can setup peer to peer by appplying port forwarding rules in your router.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜