我有以下启动WCF P2P服务的代码:
private static readonly EndpointAddress EndpointAddress =
new EndpointAddress("net.p2p://eigenein.Test.Wcf");
...
public void Start()
{
NetPeerTcpBinding binding = new NetPeerTcpBinding();
binding.Security.Mode = SecurityMode.None;
ServiceEndpoint endpoint = new ServiceEndpoint(
ContractDescription.GetContract(typeof(IChat)),
binding,
EndpointAddress);
endpoint.Behaviors.Add(new ProtoEndpointBehavior());
host = new Chat();
channelFactory = new DuplexChannelFactory<IChatChannel>(
new InstanceContext(host), endpoint);
channel = channelFactory.CreateChannel();
channel.Open();
}
据我了解,WCF自动确定侦听端口和连接到其他对等端口的端口。但我可以为每个对等设置两个特定的不同端口:要侦听的端口和连接到另一个对等端的特定端口?类似的东西:
private static readonly EndpointAddress SourceEndpointAddress =
new EndpointAddress("net.p2p://eigenein.Test.Wcf:808");
private static readonly EndpointAddress TargetEndpointAddress =
new EndpointAddress("net.p2p://eigenein.Test.Wcf:909");
我想要实现的目标:允许对等体通过静态NAT端口映射进行连接。我无法改变这些映射。