Server Code :
Thread thdUDPServer;
private void Server_Load(object sender, EventArgs e)
{
thdUDPServer = new Thread(new ThreadStart(serverThread));
thdUDPServer.Start();
}
UdpClient udpClient;
public void serverThread()
{
udpClient = new UdpClient(53);
while (true)
{
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
Byte[] receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
string returnData = Encoding.ASCII.GetString(receiveBytes);
listBox1.Items.Add(RemoteIpEndPoint.Address.ToString() + ":" + returnData.ToString());
}
}
Client Code :
UdpClient udpClient;
private void Client_Load(object sender, EventArgs e)
{
udpClient = new UdpClient();
}
private void button1_Click(object sender, EventArgs e)
{
udpClient.Connect(textBox1.Text, 53);
Byte[] senddata = Encoding.ASCII.GetBytes("Hello World");
udpClient.Send(senddata, senddata.Length);
}
Working on local network but i need global.
Details :
- Microsoft Defender off.
- Run as admin (For Server App and Client App)
Example :
udpClient.Connect(95.10.xxx.13, 53);
Where am I doing wrong? How can i send data over global network using another method?