المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Detecting the correct outside port



C# Programming
06-01-2009, 07:11 PM
Before I can ask the question I'll have to describe the situation:
There is a server and there are some clients, but the only thing server does is remembering which clients there are and then giving that information to clients which ask for it. So far so good, except that the clients are listening on some port (which is fixed on the inside of their NAT, say 1000). But obviously this information won't do anyone any good - they'd need the outside port. But how can you get it? I tried binding the socket that talks with the server to the same inside port (so that the server would see the correct port) but then it fails to connect. And the client itself seems to have no way to detect what outside port it is using..
So, what can I do about this? Do I need to throw the entire design into the bin (if so, what should it be like?)