开发者

New To Socket Programming, Need Help Understanding How To Connect

开发者 https://www.devze.com 2022-12-19 22:29 出处:网络
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.

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 Conn开发者_如何转开发ect 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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号