views:

250

answers:

4
+2  Q: 

Callback Function

I have a method called funct which i want to have as my callback function when i am using the beingreceive socket method in c#.

s.BeginReceive(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None,
               new AsyncCallback(funct), null);

The error that am getting is:

No overload for 'funct' matches delegate 'System.AsyncCallback'

What might be the problem here?

+2  A: 

You can't just use any method for your callback. The function has to have a specific signature (parameter list).

Joel Coehoorn
+3  A: 

"funct" must be a method with the following signature:

void funct(IAsyncResult ar) { }
Rex M
A: 

How does your 'funct' method signature looks like ?

Does it return void ?

Does it have exactly one parameter of type IAsyncResult ?

In other words, does your 'funct' method conform to the Asynccallback delegate ?

Frederik Gheysels
A: 

what is the funct? is it a delegate? if it is, it's signature is not compatibile with AsyncCallback delegate.

funct must be a method looking like this:

void SomeMethod(IAsyncResult ar)
Krzysztof Koźmic