TCPListener和客户端 [英] TCPListener and client

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

问题描述



对于我的工作,我需要制作一个小型(VB.NET)应用程序以与客户聊天.我们选择采用这种应用程序样式,而不是Web样式.

这个想法很简单:
1.其中一台计算机(客户/我们)需要是一台服务器.我已经做到了,以便谁启动chatapplication是服务器(由应用程序启动的Windows服务完成).
2.当客户启动然后使用应用程序时,Windows服务启动,办公室中的我们一个人收到消息,我们可以连接到客户计算机.
3.当客户关闭应用程序时,其计算机上的Windows服务将停止.

上面的要点可以正常工作,达到99%完美...在局域网上.但是应用程序需要在LAN上运行.这里的问题是TCPListener需要一个端口,而我(程序员)不知道客户可以使用哪个端口.
另一个问题是路由器.基于软件的防火墙将通知用户,因此可以看到应用程序尝试连接到Internet.路由器什么都不显示.

长话短说:
我知道我无法避开路由器(如果可以的话,请让我知道:-O).所以这里的问题是:
如何避免客户必须转发端口才能使用该应用程序?还有什么可以代替TCPListener/-Client使用的吗?
或者,如果还有其他人有更好的解决方案:请这样做!

在此先感谢您,并非常感谢您的帮助!

Hi,

For my work I need to make this small (VB.NET) application to chat with customers. We have chosen to make this application-style, not web-style.

The idea is very simple:
1. One of the computers (customer / us) needs to be a server. I have made it so that who starts the chatapplication is the server (done by a windows-service that is started by the application).
2. When a customer starts then app, the windows-service is started and one of us at the office get a message and we can connect to the cusomter-computer.
3. When the customer closes the app the windows-service on his/her computer is stopped.

The points above work fine, for 99% perfect... On local network. But the application needs to run over LAN. The problem here is that the TCPListener needs a port and I, the programmer, does not know what port the customer has available.
The other problem is routers. A software-based firewall will notify the user, so it is visible that an app tries to connect to the internet. A router doesn''t show anything.

Long story short:
I know I can''t avoid a router (if I can, please let me know :-O ). So the questions here are:
How can I avoid that a customer has to forward ports to make use of the application? Is there somethingelse that I can use instead of TCPListener / -Client?
Or if anyone else has a better solutions: Please do!

Thanks in advance and help is much appreciated!

推荐答案

这应该使您入门:
使用.Net套接字的简单聊天应用程序 [
这是一种选择:
如果要让客户端主动侦听客户端计算机上的端口,则可能需要将此信息存储在中央数据库中以简化管理.客户端可以在初始化期间从服务器读取其配置信息.

另一个可能更好的替代方法是使用System.Net.PeerToPeer命名空间下的功能.
这是
对等频道聊天 [
This should get you started:
Simple Chat Application Using .Net Sockets[^]

Usually only the server needs a "fixed" port.

Here is one alternative:
If you want your clients to activly listen to a port on the client machine, you probably need to store this information in a central database to ease management. The client can read it''s configuration information from the server during initialization.

Another, and maybe better alternative is to use the functionality under the System.Net.PeerToPeer namespace.
Here is an example Peer Channel Chat[^]

Regards
Espen Harlinn


查看防火墙是否允许您指定应用程序而不是端口号.大多数软件防火墙都应允许这样做.我认为即使我的硬件防火墙也可以.当然,大多数地方都有硬件防火墙设备以及正在运行的软件防火墙,因此这可能成为一个争论点.

编辑(我对您评论的回复)===================

不必修改防火墙.您将不得不在您的应用程序或文档中添加一些措辞,为他们提供打孔的一般说明.您唯一的(也是最佳的IMHO)资源是基于Web的聊天系统.不需要特殊的防火墙设置.实际上,我可能会使其成为Silverlight应用程序.
See if your firewall will allow you to specify an application instead of a port number. Most software firewalls should allow this. I think that even my hardware firewall does. Of course, most places have both a hardware firewall appliance in place, as well as software firewalls running, so it might become a moot point.

EDIT (my response to your comment) ====================

There''s no getting around having to modify the firewall. You''re going to have to put some sort of verbage into your application or documentation giving them general instructions for punching a hole. Your ONLY other (and best IMHO) recourse is to go with a web-based chat system. No special firewall setup is needed for that. In fact, I would probably make it a Silverlight application.


您描述的设置听起来有点麻烦.您说您已经准备好拥有Windows服务,但是该服务在客户端运行.为什么不让服务在您的24/7服务器之一上运行.它会暴露在客户已知的端口上,并且当客户端通过聊天应用程序连接时,支持人员的聊天客户端上会显示一条消息.
如果当前没有支持人员聊天客户端连接到聊天服务器,则会将上报邮件发送给支持服务主管.

支持请求的消息将显示在支持人员的所有客户上,并且一旦有人回复,该消息就会从该列表中获取.

你觉得呢?

问候,
曼弗雷德(Manfred)
The setup you describe sounds a little cumbersome. You said you all ready have a windows service, but it runs on the clients side. Why not have the service run on one of your servers 24/7. It would be exposed on a port that you make known to your customers and when a client connects via the chat application a message is shown on the chat clients of the support personnel.
If no support personnel chat clients are currently connected to the chat server an escalation mail is sent to the support service executive.

The message of support requests will be shown on all the clients of the support personnel and as soon as someone responds it will be taken from that list.

What do you think?

Regards,
Manfred


这篇关于TCPListener和客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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