I have a program shown below:
Socket receiveSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
EndPoint bindEndPoint = new IPEndPoint(IPAddress.Any, 3838);
byte[] recBuffer = new byte[256];
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
receiveSocket.Bind(bindEndPoint);
receiveSocket.Receive(recBuffer);
}
and it is working but when I want to just listen to a specific IP address it does not work, it throws an exeption "the requested address is not valid in context"
new code: EndPoint bindEndPoint = new IPEndPoint(IPAddress.Parse("192.168.40.1"), 3838);