P
paal.andreassen
I have a problem. I have two instances of a client-server application
running on two different machines A and B.
A has a listening service, that listens for connections from B
B has a listening service, that listens for connections from A
The problem is what IP to bind the listening service to. I can find
all local ip-addresses this way:
IPHostEntry hostEntry =
Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ipAdress in hostEntry.AddressList)
{
Console.WriteLine(ipAdress.ToString());
}
But how on earth do I know which one to bind and listen to? There's a
mix of IPv4 and IPv6 addresses, virtual vmware addresses, one from the
wireless wifi card and one from the ethernet cable.
Argh...
The server component I'm using has a single "void Listen(string ip,
int port)" method. Even if I manage to listen on all addresses, how
will B know which one of A's to connect to? A sends B it's ip-address
using a different schema (but's it in a common database). But I still
need to put A's "external" address down.
running on two different machines A and B.
A has a listening service, that listens for connections from B
B has a listening service, that listens for connections from A
The problem is what IP to bind the listening service to. I can find
all local ip-addresses this way:
IPHostEntry hostEntry =
Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ipAdress in hostEntry.AddressList)
{
Console.WriteLine(ipAdress.ToString());
}
But how on earth do I know which one to bind and listen to? There's a
mix of IPv4 and IPv6 addresses, virtual vmware addresses, one from the
wireless wifi card and one from the ethernet cable.
Argh...
The server component I'm using has a single "void Listen(string ip,
int port)" method. Even if I manage to listen on all addresses, how
will B know which one of A's to connect to? A sends B it's ip-address
using a different schema (but's it in a common database). But I still
need to put A's "external" address down.