Bug 4674 - Socket.BeginReceive never calls callback
Summary: Socket.BeginReceive never calls callback
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 2.10.x
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-04-26 15:18 UTC by paul firth
Modified: 2018-03-13 11:07 UTC (History)
4 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description paul firth 2012-04-26 15:18:45 UTC
Hi there,

I'm having a problem with asynchronous socket calls...

BeginReceive never has its callback called. Using the following code:

SocketError error;
socket.BeginReceive(context.Buffer, 0, context.Buffer.Length, SocketFlags.None, out error, DoReceive, context);

The callback DoReceive is never called. The error is output as 'Success'.

Manually calling socket.Receive(context.Buffer) results in correct data.

I've tested this on windows mono build version 2.10, 2.10.8 and linux centos mono build version 2.10.2 and all have the same result.

When run on .NET built for windows, there is no such problem.

Cheers, Paul.
Comment 1 Gonzalo Paniagua Javier 2012-04-26 17:50:57 UTC
I am sure that if I try this it will work because I will not be testing *exactly* the same code that you tested. Please, attach a self-contained test case that helps us reproduce the problem.
Comment 3 Gonzalo Paniagua Javier 2012-04-27 10:39:58 UTC
I get an error for both projects: error CS2001: Source file `TcpServer.cs' could not be found

Ideally, you should try to extract a smaller test case. Just as you don't want to debug mono, I don't want to debug your code ;-). Are you familiar with tcpdump/wireshark? It would also help to get the output of that. Perhaps there is no actual data available to read and that's why the callback in BeginReceive() is never called.
Comment 4 paul firth 2012-04-27 10:50:05 UTC
Sorry, the solution you need to build is here:


I've just retested and it compiles from fresh fine in VS2010.

Did you try the tests I suggested on the binaries which are indeed inside that zip file? They demonstrate the problem and show that it is not data related.


you need to be in directory CSServer/bin/Debug/ before you run mono because it requires a dll which is located there.

Cheers, Paul.
Comment 5 Nathan 2012-09-16 18:52:01 UTC
I also had this problem (I was using the Alchemy Websockets code) with Windows and 2.10.8. I fought with this all day, the callback of the beginReceive was never getting called. It worked just find using .Net instead of Mono.
I upgraded to the 2.11.4 Alpha and now the callback is being called.
Comment 6 Marek Safar 2018-03-13 11:07:37 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and reopen the bug report.

Thank you!

Note You need to log in before you can comment on or make changes to this bug.