开发者

Winsock 2.0 Will Not Connect to Public IP Address

开发者 https://www.devze.com 2023-03-31 03:22 出处:网络
So I am trying to build a simple text IM program to get into the wonderful world of networking. I have written 2 programs using Winsock 2.0 with C++: a server and a client. I have specified a UDP conn

So I am trying to build a simple text IM program to get into the wonderful world of networking. I have written 2 programs using Winsock 2.0 with C++: a server and a client. I have specified a UDP connection via the socket creation:

SOCKET Socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);

Everything works when I try to connect to the server using my local IP address. However, It will not connect when I 开发者_运维问答use my internet IP address. I am fairly certain that it is NOT a firewall issue, because I did multiple tests with both my firewall and antivirus disabled. Is there something I am missing? Can you think of any other reasons why it would be able to connect via the local address, but not the public IP address? Thank you very much!


Most likely the public IP address you have is owned by your network router appliance. It needs to be configured to pass traffic onto your computer

  public IP            internal router
   address +--------+  IP address  +---------+
      v    |        |  v           |         |
 ----------+ router +--------------+ desktop +
           |        |           ^  |         |
           +--------+   internal   +---------+
                      desktop IP address

http://portforward.com/

0

精彩评论

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

关注公众号