General discussion
January 21, 2006 at 01:14 AM
harishdixit

How to connect a NAT behind machine

by harishdixit . Updated 20 years, 8 months ago

please tell me how a machine connected to internet will send Connect request to it’s LAN client behind a NAT. Because first request will go to the LAN server. And this LAN client is not directly visible to us.

it returns “Socket is not connected” error code – WSAENOTCONN
10057.

situation is like:

————- —————— ——— ——–
|Machine A| ——— >> |internet(WAN)| ————>> |Server|—– >|M/C B|
————- ——————- ——— ——–

(A LAN)

machine A is not in a LAN, it is connected to internet with static IP. while B is in a LAN, behind a Server . and this server having public IP Address. B is not directly accessible , we can access it only through server. my one application is running on B and can connect to A when a connection request is made. My another apllication is running on A.

A has a static IP, while machine B is not publicly visible outside world. but we know IP address of server,and of machine A and machine B. and also port no on B and A.

problem is that when i send a connect request to B from A, via Server
then connection is not established.

If we try to establish a connection from B to A then it succeded,
while from A to B it will not.

port forwarding is one solution.But my situation is that
there may be many machines on the LAN and many outside machines
can connect to these LAN machines. Means (m to n) relationship is there.
So in this case how port forwarding will work ?

each time in my connect() request my destination
machine address will be changed.

Is there any solution by which we can do port forwarding for
any destination machine.Means it should be independent
on any manual entry in NAT device.

I am using socket programming Winsock 2 API in VC++.

regards
Harish.

This discussion is locked

All Comments