[Mono-bugs] [Bug 395168] New: Async Sockets with List<ArraySegment<byte>> -- Does Not Work

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed May 28 13:54:02 EDT 2008


           Summary: Async Sockets with List<ArraySegment<byte>> -- Does Not
           Product: Mono: Runtime
           Version: 1.9.0
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: io-layer
        AssignedTo: dick at novell.com
        ReportedBy: kkoch at centralert.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Customer

Async sockets with List<ArraySegment<byte>> does not appear to work.  I am
working with Mono on Windows AND on the Mac.  I can get BeginReceive to work
using buffers, but not with List<ArraySegment<byte>>.  Basically at some point
before the callback function is called I'm getting an Access Violation
exception in Mono itself.  The same problem occurs with BeginSend.

I have written about the simplest possible test code shown below:

 public class Tester
    Socket _listenSocket;
    Socket _outgoingSocket;
    Socket _connected;
    byte[] buffer = new byte[10000];
    byte[] outBuffer = new byte[10000];
    List<ArraySegment<byte>> _list = new List<ArraySegment<byte>>();

    public Tester()
      IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, 44444);
      _listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,

      _outgoingSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
      _outgoingSocket.Connect("localhost", 44444);
      _connected = _listenSocket.Accept();
      ArraySegment<byte> seg = new ArraySegment<byte>(outBuffer, 0, 10);
      _connected.BeginReceive(_list, SocketFlags.None, OnReceiveComplete,
      _outgoingSocket.BeginSend(buffer, 0, 0, SocketFlags.None, OnSendComplete,
      SocketError err;
      _outgoingSocket.Send(outBuffer, 0, 10, SocketFlags.None, out err);

    public void OnReceiveComplete(IAsyncResult ar)
      // Never gets called
      int bytesReceived = _connected.EndReceive(ar);
      Console.WriteLine("Bytes received: {0}", bytesReceived);


    public void OnSendComplete(IAsyncResult ar)
      // Does get called
      int bytesSent = _outgoingSocket.EndSend(ar);


Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list