WCF TCP 和 HTTP 端点可以具有相同的端口吗? [英] Can WCF TCP and HTTP endpoints have the same port?

查看:36
本文介绍了WCF TCP 和 HTTP 端点可以具有相同的端口吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对公开 HTTP 和 TCP 接口的 WCF 服务器感兴趣.它将与 Silverlight 客户端一起使用,因此我们的想法是 HTTP 接口将用于安全通信,而 TCP 将用于其余时间.

I'm interested in one WCF server exposing both HTTP and TCP interfaces. It'll be used with Silverlight clients, so the thinking is that the HTTP interface will be for secure communications while TCP will be used the rest of the time.

这两个接口是否有可能在它们的端点中使用相同的端口,例如http://localhost:9000/ 和 net.tcp://localhost:9000/?

Is it possible for these two interfaces to use the same port in their endpoints, e.g. http://localhost:9000/ and net.tcp://localhost:9000/?

推荐答案

不,这是不可能的.如果启用了 TCP 端口共享服务,则可以让多个服务侦听同一个 TCP 端口.Windows HTTP 侦听器还允许您让多个服务共享一个公共端口(例如,控制台应用程序和 IIS 都可以在不同 URL 的端口 80 上侦听).但是你不能在同一个端口上使用多个绑定.

No this is not possible. If you have the TCP port sharing service enabled, you can have multiple services listening on the same TCP port. Windows HTTP listener will also allow you to have multiple services sharing a common port (for example, a console application and IIS can both listen on port 80 at different URL's). But you can't use multiple bindings on the same port.

但无论如何我都没有真正看到这样做的好处.我个人会将 HTTP 端点保留在端口 80 上,当然您的 TCP 端点仅限于较高的端口范围.不过,我不确定您要启用什么场景.

But I don't really see the advantage of doing that anyway. I would personally leave the HTTP endpoint on port 80 and of course your TCP endpoint is restricted to an upper port range. I'm not sure what scenario you're trying to enable though.

这篇关于WCF TCP 和 HTTP 端点可以具有相同的端口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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