Newbie:Connecting via TCP to a machine behind a NAT router

N

Navin Mishra

HI,

I've built a .NET service that sends events to registered clients via TCP.
A client need to provide their IP and port when registering. And service
opens TCP link to the client on the provided IP and port. Everything is fine
except when the client is behind a NAT router in which case the client IP
like 192.168.11.2 is not reachable from the service.

Whar are the possible workarounds for this ?

Thanks in advance and regards

Navin
 
A

Arjen de Blok

A solution is to use the connection from the client to the server to send
the events, instead of making a new connection from the server to the
client.

Another solution is when the server gets a new connection from a client to
ask for the RemoteEndpoint property of the socket. When the clients have a
fixed port that is opened then you can connect to it.
 
N

Navin Mishra

Thanks for response. I was trying the second option. The server is a web
service in my case. When the client(which is behind a NAT router) calls a
web method, the host address in Context.Request.HostAddress is something
which is not reachable from the server machine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top