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(str ing ipAddress,int port)
{
IPEndPoint ep=new IPEndPoint(IPAd dress.Parse(ipA ddress),port);
byte[] buffer=new byte[1500];
int receivedBytes=s ocket.ReceiveFr om(buffer,ref ep);
byte[] packet=new byte[receivedBytes];
Array.Copy(buff er,0,packet,0,r eceivedBytes);
return packet;
}
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(str ing ipAddress,int port)
{
IPEndPoint ep=new IPEndPoint(IPAd dress.Parse(ipA ddress),port);
byte[] buffer=new byte[1500];
int receivedBytes=s ocket.ReceiveFr om(buffer,ref ep);
byte[] packet=new byte[receivedBytes];
Array.Copy(buff er,0,packet,0,r eceivedBytes);
return packet;
}
Comment