Avik
Avik

Reputation: 2137

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?

Upvotes: 5

Views: 1466

Answers (4)

Krzysztof Kozmic
Krzysztof Kozmic

Reputation: 27374

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)

Upvotes: 1

Frederik Gheysels
Frederik Gheysels

Reputation: 56934

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 ?

Upvotes: 0

Rex M
Rex M

Reputation: 144122

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

void funct(IAsyncResult ar) { }

Upvotes: 6

Joel Coehoorn
Joel Coehoorn

Reputation: 415745

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

Upvotes: 2

Related Questions