I keep getting the same error code on s.bind:
{"The requested address is not valid in its context" }.
Here is the code that produces the error:
IPHostEntry hostEntry = Dns.Resolve("NPIFA21AE");
IPEndPoint endPoint = new IPEndPoint(hostEntry.AddressList[0],
9100);
Socket s = new Socket(endPoint.Address.AddressFamily,
SocketType.Dgram,
ProtocolType.Udp);
// Creates an IPEndPoint to capture the identity of the sending
host.
IPEndPoint sender = new IPEndPoint(hostEntry.AddressList[0], 9100);
EndPoint senderRemote = (EndPoint)sender;
// Binding is required with ReceiveFrom calls.
try
{
s.Bind(endPoint);
}
catch (Exception e)
{
Console.WriteLine("Winsock error: " + e.ToString());
}
//s.Bind(endPoint);
byte[] msg = new Byte[1256];
// Console.WriteLine ("Waiting to receive datagrams from client...");
// This call blocks.
s.ReceiveFrom(msg, ref senderRemote);
s.Close();
Any help is appreciated.
Thanks,
Trint