I have currently been trying to go over some code on GitHub for a UDP DNS Server. The DNS Server is meant to allow for proxy-like MITM behaviour so I can look at the, redirect or block the DNS packets. Reading through the code I saw two functions that look very similar but I can't quite grasp the difference between the two. I have tried to look through the Microsoft documentation but that had not helped me understand the difference either. This is the extract of code I am referring to. The project in question that I am reading through can be found here: Portable DNS Proxy
public byte[] directRead()
{
byte[] msg = client.Receive(ref ep);
return msg;
}
public void read()
{
Console.WriteLine("Initializing Read");
client.BeginReceive(new AsyncCallback(recvAsync), null);
Console.WriteLine("Read async started");
}
In this instance the variable named client is simply an instance of the UdpClient class and the variable ep is the instance of the IPEndPoint class.