tags:

views:

94

answers:

2

I have a C++ Program listening for incoming socket connections on port 2222. I have an Adobe AIR/Flex application that attempts to connect to it, when I click a button.

When I Connect To My Socket Over My Intranet, My C++ program hears and accepts the incoming socket connection and Everything Works Fine:

var Sock:Socket=new Socket("192.168.1.100",2222);

But When I Try To Connect Using My Real IP, I Get Error #2031:

var Sock:Socket=new Socket("76.18.24.118",2222);

Both programs are running on my laptop computer. I am behind a router, but have configured that router with port forwarding so that port 2222 maps to my laptop.

What Am I Missing? I am very new to this, so perhaps I'm missing something obvious to you smarties.

+2  A: 

What does the error code mean (see your docs for socket) Are you sure the receiving server process is alive?

The traditional starting point is Beej's guide

Martin Beckett
+1  A: 

Port forwarding does not mean that you can use an external IP address, your laptop is still on the private 192.168 network. What it means is that when someone tries to connect on 78.18.24.118:2222 the router converts the IP address to 192.168.1.100:2222. This effectively allows you to run a server inside your network but allows an outside client to connect to you.

Look up DNAT for more information.

doron