C# - Need help connecting to IPEndPoint
-
11-02-2021 - |
Question
Ok, I am trying to use the System.Net.Sockets part of the .Net Framework 4 to connect to an IPEndPoint.
First I declare the IP address as a variable like so
IPAddress myIpAddress = IPAddress.Parse("10.10.15.200");
Then I declare my IP endpoint as a variable like so:
IPEndPoint ip = new IPEndPoint(myIpAddress, 5001);
Then I try and bind to this socket, like so:
socket.Bind(ip);
The response I get is as follows:
The requested address is not valid in its context.
However this is not the case. The IP address exists and is currently active. The IP address in question is a VOIP phone on a SIP trunk.
Thanks in advance.
John
Solution
Bind
is used to associate to a local address and port and is where the packets will be marked as coming from. You need to use Connect
instead.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow