Does the function below returns an UDP packet, for example, from the
local machine? Why does it give me an error: "The best overloaded
method match for ReceiveFrom... has some invalid arguments". Why this
error?
How can I receive a packet from a specific adapter, for example, my
local machine? Is there a better way? This way won't work. The error is
in "ref ep"... how does receiveFrom work?
Thanks.
public byte[] ReceiveFrom(string ipAddress,int port)
{
IPEndPoint ep=new IPEndPoint(IPAddress.Parse(ipAddress),port);
byte[] buffer=new byte[1500];
int receivedBytes=socket.ReceiveFrom(buffer,ref ep);
byte[] packet=new byte[receivedBytes];
Array.Copy(buffer,0,packet,0,receivedBytes);
return packet;
}