How to pick a port number?
I am trying to develop an iPhone p2p application.
I am going to use a centralized server and users will u开发者_JS百科pdate their IP addresses to the server. I want to set up a connection between users, regardless of what network users belong to.
I was going to use a fixed port number and someone pointed out that a router, if the user connected via Wi-Fi, might block the port number I manually set up.
How do I fix this problem?
You might look into NAT traversal strategies like UDP hole punching, which is one method of supporting p2p communication when the endpoints may not have routeable IP addresses (for example, if they're behind NAT routers). Philip makes a good point in his answer, though: it's possible to configure routers and firewalls to deny p2p traffic, so for maximum flexibility you might want the ability to fall back to a client-server mode (using your server as an intermediary).
You can't fix this problem. The administrator of a "router" is free to block arbitrary port numbers.
精彩评论