I'm trying to control the network interface used for a web service call by setting the local endpoint. The error I'm getting indicates that the local IP Address that isn't recognised by the machine. The local address I'm using is returned by ipconfig and to make sure I also ran the following code snippet (simplified down to the TCP level):
foreach(NetworkInterfaceadapterinNetworkInterface.GetAllNetworkInterfaces() ) {
IPAddressaddr = adapter.GetIPProperties().UnicastAddresses[0].Address;
IPEndPointlocalEp =newIPEndPoint(addr, 60000);
IPEndPointremote =newIPEndPoint(IPAddress.Parse("192.168.203.26"), 8080);
TcpClientlocal =newTcpClient(localEp);
local.Connect(remote);
local.Close();
}
There is only one adapter with one IP Address and the port is not in use according to netstat.
If I don't bind the client to a local endpoint the connection is OK so the remote endpoint is reachable.
Am I missing something subtle here?
Its hard to believe that something so fundamental is broken.