My client/server program created in vb6(winsock) dont work on WAN but perfectly works n LAN Why?

只愿长相守 提交于 2019-12-24 12:55:14

问题


I've created a simple client/server program with the help of winsock in vb6. It perfectly works on LAN but the problem is it doesn't work on WAN. All ports are already open, Firewall is already Off, I have dynamic IP so I used No-ip to get named IP address.
One more think I want to ask is , is it important to open port on both client and server? For eg- I've created the program on port 50505 and on the client computer the port is open but is it important to open 50505 on server also??

Here is my project.

If anyone could find the problem please let me know. I would appreciate a lot


回答1:


Okay, first make sure that in the client side program that the Localport is not set to anything because Windows will assign it one, but the RemotePort is set to 50505. On the server side, the RemotePort is set to nothing, and the LocalPort is set to 50505.

Next you need to make sure your server has a static IP on your network. So if your router's LAN IP is 192.168.1.1 you need to set your server's to something like 192.168.1.50, just make sure that it doesn't get put in the range or the DHCP server (That's the server that gives each computer a IP address from the router).

Next you need to setup your router for "Port forwarding". Be default your router had no idea what to do with data that the internet sends to it. You have to setup the router to forward any data from port 50505 to your server on your network.

While this seams really long and drawn out, it shouldn't take more than 5-10 min's to setup.

Good luck!




回答2:


You need to configure the router that the server is behind to forward connections on that port to the computer running the server.

Otherwise, the client will not be able to connect to the server.



来源:https://stackoverflow.com/questions/14326441/my-client-server-program-created-in-vb6winsock-dont-work-on-wan-but-perfectly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!