Hi there,
My machine have 2 Network Adapters (NIC). I try to assign different IP
to 1 adapter using IPHelper's AddIPaddress API. Then I used Socket to
bind that IP and send to another machine IP address.
I was unable to send sucessfully. I can send only another NIC IP in my
machine. How do i set socketoptions or gateway setting whenever after i
add new ip address?
Here is code example
// returnCode = AddIPAddress(staticIP, staticMask, adapterIndex, ref
nteContext, ref nteInstance);
Socket s = new
Socket(AddressFamily.InterNetwork,SocketType.Strea m,ProtocolType.Tcp);
byte[] msgBytes = System.Text.Encoding.ASCII.GetBytes("Hello Server");
// new IPaddress I assign - 10.23.25.101
IPEndPoint localEP = new
IPEndPoint(Dns.Resolve("15.23.25.41").AddressList[0],0);
IPEndPoint remoteEP = new
IPEndPoint(Dns.Resolve("192.168.2.220").AddressLis t[0],9000);
s.Bind(localEP);
s.Connect(remoteEP);
s.Send(msgBytes);
s.Shutdown(SocketShutdown.Both);
s.Close();
Any idea would be appreciated. thanks in advance