I have the following code that starts a WCF P2P service:
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();
}
As I understand, WCF automatically determines the listening port and the port to connect to the other peer. But can I set up two specific different ports for each peer: the port to listen to and the specific port to connect to the other peer? Something like:
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");
The thing I want to achieve: allow peers to connect through a static NAT port mappings. I'm not able to change these mappings.