I go through this article example :
C# UDP Broadcast and receive example
But in this example the IP Address is taking the Local IP Address (ex: 192.168.xx.xx)
var from = new IPEndPoint(0, 0); // Taking Local IP Address (ex: 192.168.xx.xx)
I want the clarification that, is it possible to give the particular IP Address like : "230.0.0.3"
I try to given the particular IP Address
static void Main(string[] args)
{
int PORT = 7716;
string ip = "230.0.0.3";
UdpClient udpClient = new UdpClient();
long udpip = Convert.ToInt64(ip.ToString()); // 'Input string was not in a correct format.'
//udpClient.Client.Bind(new IPEndPoint(data, PORT));
var from = new IPEndPoint(udpip, PORT); //IPAddress.Any
if (from.Address.ToString() == "230.0.0.3" && from.Port.ToString() == "7716")
{
Task.Run(() =>
{
while (true)
{
var recvBuffer = udpClient.Receive(ref from);
Console.WriteLine(Encoding.UTF8.GetString(recvBuffer));
}
});
}
// var data = Encoding.UTF8.GetBytes("ABCD");
//udpClient.Send(data, data.Length, "255.255.255.255", PORT);
Console.ReadLine();
}
While executing this program I'm getting this error
'Input string was not in a correct format.'
Note : Data should receive from IP Address : '230.0.0.3' and Port Number : 7716
Give me the suggestion. How can I achieve this ?
I'm new to the UPD Socket port concepts and logics.