C#互联网聊天 [英] C# Internet Chat

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

问题描述


我想编写一个聊天应用程序.我已经找到了100个教程,但每个教程只是一个本地聊天.但是我想和用户写一个Chat',但可以不必在同一网络中.我想写一个像Skype,ICQ,MSN之类的聊天室....
但是我不知道怎么做!如何在同一个网络中的两台计算机之间建立连接?



最好的问候
Andre

Hi,
I want to write a Chat application. I have found 100 of tutorials but every one was just a local chat. But I want to write a Chat ´with users and which can but dont have to be in the same network. I want to write a chat which is like Skype, ICQ, MSN, and so on....
But I dont know how! How can I create a connection beteen two computers which arent in the same network?



Best regards
Andre

推荐答案

您进行的连接与本地网络上的连接完全相同.但是,您可能还需要克服其他障碍,例如防火墙和路由器.

要连接位于防火墙或路由器后面的两台计算机,您需要一台直接连接到Internet的服务器(而不是在任何路由器之后,或者设置为DMZ服务器,或者为应用程序将要使用的端口设置端口转发)这将有利于两台计算机的连接.
您可以通过搜索"NAT遍历"找到大量教程来了解路由器.请注意,由于路由器的设置方式或防火墙阻止了连接,您无法始终连接两台计算机.
You make a connection exactly the same as on a local network. There are however additional obstacles that you may need to overcome, such as firewalls and routers.

To connect two computers that are behind firewalls or routers you will need a server that is directly connected to the internet (not behind any routers, or set as the DMZ server, or has port forwarding set up for ports that your application will be using) that will facilitate the connection of the two computers.
You can find a ton of tutorials for getting past routers by searching for ''NAT Traversal''. Be aware that you cannot always connect two computers due to the way that the routers may be set up, or because a firewall is blocking the connection.


您可以使用套接字连接.为此,您需要一台具有真实IP的服务器PC.所有客户端应用程序都知道服务器的IP和端口.每个客户端都通过服务器相互连接.
You can use socket connection. For this you have to need a server pc, which have a real ip. all client application know the server ip & port. each client connect each other via the server.


您可以使用套接字连接.为此,您需要一台具有真实IP的服务器PC.所有客户端应用程序都知道服务器的IP和端口.每个客户端都通过服务器相互连接.
You can use socket connection. For this you have to need a server pc, which have a real ip. all client application know the server ip & port. each client connect each other via the server.


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

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