When I want to received UDP datagrams asynchronously, I write call BeginReceiveFrom of a System.Net.Sockets.Socket class. The BeginReceiveFrom method expects an Endpoint as the remoteEP parameter.
public IAsyncResult BeginReceiveFrom (
byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
ref EndPoint remoteEP,
AsyncCallback callback,
Object state
)
This Method starts an asynchronous receive and cannot return any result in remoteEP since it returns immediately. Is this parameter for a kind of filtering or will it be modified on receive completion?
In the receive handler I call EndReceiveFrom, where I also have to pass a reference to an Enpoint object as the endPoint parameter.
public int EndReceiveFrom (
IAsyncResult asyncResult,
ref EndPoint endPoint
)
The EndReceiveFrom indicates with this Endpoint object the sender of the UDP frame. Why must I pass a remoteEP to the BeginReceiveFrom and can I avoid this?