I am curious where can I find out that AcceptClient as a callback of BeginAcceptSocket needs to have IAsyncResult as a parameter. In the MSDN article there is only mentioned that return value of BeginAcceptSocket is IAsyncresult. But how could I know that it has to be passed to callback?
Thanks!
public server(int port)
{
listener = new TcpListener(System.Net.IPAddress.Any, port);
listener.BeginAcceptSocket(this.AcceptClient,null);
}
private void AcceptClient(IAsyncResult ar)
{
}
From its documentation, you know that
BeginAcceptSocketexpects anAsyncCallbackas its first parameter, so the next step is to read the documentation for theAsyncCallbackdelegate, which is itself a type with the following method signature: