TCP聊天客户端/服务器(端口转发?) [英] TCP Chat Client/Server (Port-Forwarding?)

查看:190
本文介绍了TCP聊天客户端/服务器(端口转发?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有点困惑.我正在创建一个TCP聊天应用程序(客户端-服务器),我的问题是在路由器后面,在服务器上. D
我是否还必须像客户端必须那样将TCP端口转发给我的本地计算机,还是因为我不希望服务器和服务器基本上处于空闲状态以等待来自客户端的连接,所以我不应该将TCP端口转发给我的本地计算机?

I am a bit confused now. I am creating a TCP Chat App (Client-Server) and my questions is im behind a router, im the server. D
Do i also have to port-forward the TCP Port to my local computer, like the Client has to do or do i have not because im the server and the server basically waits in idle for a connection from client side?

推荐答案

您可能需要.如果您使用的本地IP地址为127.0.0.1,则连接到网络的任何路由器都将无法连接,但是如果您使用的是192.168.1.678这样的专用IP地址,则任何人都将无法连接.您需要找到您的公共IP地址.
You may need to. If you are using a local IP address of 127.0.0.1 then no any router connected to your network will be able to connect but if you are using a private ip address such as 192.168.1.678 then nobody will be able to connect. You need to find your public IP address. https://www.google.com/search?q=whats+my+public+ip+address&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a#hl=en&client=firefox-a&hs=8jV&tbo=d&rls=org.mozilla:en-US:official&spell=1&q=what%27s+my+public+ip+address&sa=X&ei=GGmZUL-IIoTH0QGdloHACg&ved=0CC0QBSgA&bav=on.2,or.r_gc.r_pw.r_qf.&fp=6badbe56f25053ec&bpcl=37189454&biw=1680&bih=957[^]
Click that link to get your public ip address. Once your public IP address is found then you need to unblock the port that you are sending and recieving tcp data with.

WARNING: DO NOT ENTER DMZPLUS MODE IF YOU ARE ON AN AT&T ROUTER. YOU WILL GET HACKED WITHIN A WEEK BECAUSE IT WILL ACCEPT ANY DATA FROM ANY PORT.

Their you go hope you continue to program you TCP/IP CHAT application :)


我已经知道如何以编程方式获取IP,但我发现只有服务器需要端口转发,客户端搜索连接后,客户不必进行端口转发,感谢ExcellentProducts的提示
I already know how to obtain my IP programmatically but i found out that only the server needs port-forwarding, the client does not have to port-forward since he searches for connection, thanks ExcellentProducts for the tips


这篇关于TCP聊天客户端/服务器(端口转发?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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