私人聊天 [英] Private chat

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

问题描述

你好
我创建了一个具有聊天室的应用程序.我想让我的用户使用像Y这样的私人聊天!信使.创建聊天室服务器时,要监听我的端口,我必须在路由器中添加该端口(我的adsl适配器充当路由器).那么我如何为拥有像我这样的路由器的用户进行私人聊天呢?

我是否需要从服务器中的客户端接收消息并传递到另一个客户端,或者我可以连接客户端P2P,并且客户端直接发送私人消息?

Hello
I created an application that has a chat room. I want to my users use a private chat like Y! messenger. When i create my chatroom server, to listen at my port i had to add that port in my router(My adsl adaptor works as a router). So how i can make a private chat for users who have a router like me?

Am i require to receive message from client in server and pass to another client or i can connect client P2P and clients send private messages directly?

推荐答案

我认为您需要阅读有关网络工作原理的文章:)

您需要记住的是,当计算机直接连接到Internet时,它具有2个IP地址.专用网络地址(例如10.0.0.10或192.168.0.159)和公用网络IP地址.

您的情况可能有所不同.我怀疑您的路由器充当网关,这意味着您的路由器连接到Internet,然后与您的专用网络上的其他PC共享该Internet连接.仍然有一个公共和私有IP地址,但是您的聊天客户端无法直接访问您的服务器应用程序.

如果是这种情况,则必须在路由器本身上设置NAT或端口​​转发.如果客户端连接到特定端口(服务器已设置为侦听的端口),那么所有这些请求都将转发到您的计算机以进行处理.

如果您不了解网络的基础知识,那么这是很多建议.我建议您使用Google的公共和专用网络,网关和端口转发.

希望对您有帮助
I think you need to go read up on how networks work :)

The thing you need to remember is that when a computer connects DIRECTLY to the internet it has 2 IP addresses. A private network address(like 10.0.0.10 or 192.168.0.159) and a public network IP address.

Your case is probably different. I suspect your router is acting as a gateway, this means that your router connects to the internet and then shares that internet connection with other PC''s on your private network. There is still a public and private IP address, but your chat clients can''t access your server application directly.

If this is the case you''ll have to set up NAT or Port Forwarding on the router itself. What this does is if a client connects to a specific port(which ever port your sever is set to listen to) all those requests are forwarded to your machine to handle.

This is alot to take in if you don''t understand the basics of networking. I suggest you go Google public and private networks, gateway, and port forwarding.

Hope this helps


这篇关于私人聊天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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