Winsock连接麻烦 [英] Winsock connection troubles

查看:92
本文介绍了Winsock连接麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始创建聊天服务器,并为我的朋友和客户端程序创建客户端程序,以便在服务器程序可以在计算机上运行的地方使用它,并且当我使用该客户端程序时,我会将客户端程序提供给我的朋友进行聊天等.


I have recently started creating chat server, and client programs for my friends and I to use where the server program would be run on my computer, and I would give the client program to my friends to chat etc. when I use the


SockAddr.sin_addr.s_addr = inet_addr("127.0.0.1");

if(connect(sConnect,(SOCKADDR*)(&SockAddr),sizeof(SockAddr))!=0);





代码部分,它可以很好地在我的计算机上工作,可以连接,并且一切都可以正常工作,但是如果我将127.0.0.1更改为我的真实IP(例如,假设其11.11.11.11),则客户端程序将无法连接. (显然,我这样做是为了使客户端程序不会尝试连接到我的朋友计算机上将要运行的端口,但是它将连接到我的端口之一)


任何帮助将不胜感激

Brett





section of code it works perfect on my computer, I can connect, and everything works perfectly, but if I change the 127.0.0.1 to my real ip (just for example lets say that its 11.11.11.11) the client program wont connect. (obviously i do this so that the client program wont try to connect to a port on my friends computer where it will be run, but it will connect to one of the ports on mine)


any help would be appreciated

Brett

推荐答案

如果您真的只更改IP地址,并且没有在地址中输入任何错误,我会闻到防火墙的味道!
检查防火墙日志,查看防火墙设置,考虑使用其他协议…

—SA
If you really don''t change anything but IP address and make no mistake in the address, I smell firewall!
Check up firewall logs, look at the firewall settings, consider using different protocol…

—SA


当您说真实地址时,日元表示您的计算机的IP还是您的外部Internet IP?
如果您使用的是互联网地址,并且拥有路由器,则可能需要在路由器上设置端口转发,或者使用upnp来为您完成此操作.
When you say real address do yen mean your computer''s IP or your external internet IP?
If you are using your internet address, and have a router then you may need to set up port forwarding on your router, or use upnp to do it for you.


好,谢谢使用我的外部IP地址,因此我将不得不设置端口转发,谢谢您的帮助
Ok thanks, I am using my external IP address, so I will have to set up port forwarding thank you for your help


这篇关于Winsock连接麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆