Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用NetTcpBinding创建WCF服务时,请使用endpoint“;“本地主机”;或机器';谁的主机名?_Wcf_Windows Services_Localhost_Nettcpbinding_Endpoint - Fatal编程技术网

使用NetTcpBinding创建WCF服务时,请使用endpoint“;“本地主机”;或机器';谁的主机名?

使用NetTcpBinding创建WCF服务时,请使用endpoint“;“本地主机”;或机器';谁的主机名?,wcf,windows-services,localhost,nettcpbinding,endpoint,Wcf,Windows Services,Localhost,Nettcpbinding,Endpoint,我有一个WCF服务,它使用NetTcpBinding并在Windows服务中运行。远程客户端连接到此服务。到目前为止,我已经将端点定义为使用“localhost” 如果主机有多个网络适配器,它是否会在所有适配器上接收消息 将计算机的主机名分配给端点而不是“localhost”是否更好 优点/缺点是什么?如果我希望客户端能够通过任何外部接口以及本地主机进行连接,我通常将URI设置为: 净。tcp://0.0.0.0 这也减轻了部署到多台机器的负担,因为您不需要在每台机器上都更改主机名,但在您的环境

我有一个WCF服务,它使用NetTcpBinding并在Windows服务中运行。远程客户端连接到此服务。到目前为止,我已经将端点定义为使用“localhost”

如果主机有多个网络适配器,它是否会在所有适配器上接收消息

将计算机的主机名分配给端点而不是“localhost”是否更好


优点/缺点是什么?

如果我希望客户端能够通过任何外部接口以及本地主机进行连接,我通常将URI设置为:

净。tcp://0.0.0.0

这也减轻了部署到多台机器的负担,因为您不需要在每台机器上都更改主机名,但在您的环境中允许这样做可能会带来安全隐患。

您可以使用 System.Environment.MachineName

例如:

new EndpointAddress(new UriBuilder {Scheme = Uri.UriSchemeNetTcp, Port = port, Host = System.Environment.MachineName}.Uri);

我需要这个完全相同的问题的答案。也许@marc_s能帮上忙?