public int ReceivePacket(byte[] buffer)
{
if (!IsOpen())
Open();
if (!IsOpen())
return 0;
IPEndPoint iep = new IPEndPoint(IPAddress.Any, localPort);
byte[] incoming = Receiver.Receive( ref iep );
int count = Math.Min(buffer.Length, incoming.Length);
System.Array.Copy(incoming, buffer, count);
return count;
}