Overlapped IO was Re: [Mono-list] threads and Async Socket methods
P Oscar Boykin
Wed, 28 Apr 2004 14:15:18 -0700
Content-Type: text/plain; charset=us-ascii
Sorry for replying to myself, but I thought some other people might
benefit from seeing a few references.
It seems what I am interested in is the following question:
Does Mono support overlapped IO on the asynchronous socket calls.
Winsock does support this. It seems the .Net framework is supposed to
support this. When I put a server under heavily load, this fails on
mono 0.31 on debian unstable.
Any Mono guru's out there care to comment on Overlapped IO on Sockets in
I have found some background links discussing various issues with
overlapped IO and unix:
Wine has had to deal with this:
Here is a discussion about IO models in winsock programming which sings
the praises of overlapped IO:
I am having a hard time writing a test case only using sockets which can
expose (what a believe to be) the bug. In my code, I have ~50 sockets
which are created with a lot of data being copied between the sockets.
At that point, I start to see sockets which just stop working. For
instance, BeginSend methods stop calling the callback function, and the
socket basically gets stuck (some internal deadlock maybe?)
I looked at the code for the System.Net.Sockets.Socket class. It seems
to implement the BeginSend and BeginReceive methods just using a Worker
without any attempt at any kind of thread safety (which I can imagine
would cause problems if you call interleaved BeginSend and BeginRead).
On Tue, Apr 27, 2004 at 05:33:04PM -0700, P Oscar Boykin wrote:
> Hello All,
> I have some code that does asynchronous Socket.BeginSend and
> Socket.BeginReceive calls.
> My question is the following:
> 1) The documentation (in monodoc) says that no instance members of
> Socket are guaranteed to be thread safe.
> 2) Given the above, is it safe to have a BeginSend call active while a
> BeginReceive call is also active? Given that the "under the hood" it
> appears that these methods are implemented with threads.
> So, to make it clear, if I have code like:
> [ other stuff here ]
> is this safe? To me, it would seem like it would not be safe if none of
> the members are guaranteed to be thread safe, but on the other hand, I
> have a C# networking book that has examples such as this.
> The reason I ask is that I have some code that (on mono 0.31) appears
> that *SOMETIMES* the BeginSend never calls the callback function to
> indicate that it finished (and the other side never gets the data).
> This is happening while a BeginReceive() is active.
> When I see bugs that happen only sometimes, it usually makes me worry
> about thread safety. It would be nice if the Begin* methods were
> designed such that there could be more than one of them active at a time
> (particularly, it would be nice to have a send going on while a receive
> was also active).
> Am I expecting too much here?
> firstname.lastname@example.org http://pobox.com/~boykin jabber: email@example.com=
> fingerprint=3DD250 4AD9 4544 B7D2 A17C 911D D608 D387 6718 D75F
> Hague Convention is Bad News: http://www.gnu.org/philosophy/hague.html
firstname.lastname@example.org http://pobox.com/~boykin jabber: email@example.com
fingerprint=3DD250 4AD9 4544 B7D2 A17C 911D D608 D387 6718 D75F
Read about net freedom: http://www.politechbot.com/
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
-----END PGP SIGNATURE-----