Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6363525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:02:58+00:00 2026-05-25T00:02:58+00:00

After playing a while with Mono, I see one strange thing – every call

  • 0

After playing a while with Mono, I see one strange thing – every call to Send(), EndSend(), SendAsync() etc return not number of bytes sent in this particular operation, but total number of bytes sent during the lifetime of a Socket.

According to various sources (including official Microsoft documentation), the number of bytes sent should reflect only last operation (which seems logical and standard), but in Mono this is different.

I’ve tried Mono 2.8.2, 2.10.5 – this behaviour is still there. Looking into sources (including master on GitHub), I see that this is “behaviour by design”, however, this contradicts to documented behaviour.

So, my question is – is this a bug in Mono, or I misunderstood something? If this is a bug – how could it happen that it lurks there for years, and nobody noticed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:02:59+00:00Added an answer on May 25, 2026 at 12:02 am

    Sorry, but can’t reproduce that with Send or EndSend. Considering test program and Mono’s source code I would say there is no bug in Mono. Details below.

    I used this code to test, it is not beautiful, however shows what should be shown:

    using System;
    using System.Net.Sockets;
    using System.Net;
    using System.Threading;
    
    namespace Test2
    {
        class MainClass
        {
            public static void Main (string[] args)
            {       
                var t = new Thread(Read) { IsBackground = true };
                t.Start();
                Thread.Sleep(300);
                var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                socket.Connect(new IPEndPoint(IPAddress.Loopback, 1234));
                for(var i = 0; i < 10; i++)
                {
                    Console.WriteLine(socket.Send(new [] {(byte) 0x12}));
                }
            }
    
            public static void Read()
            {
                var s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                s.Bind(new IPEndPoint(IPAddress.Loopback, 1234));
                s.Listen(1);
                var accepted = s.Accept();
                while(true)
                {
                    accepted.Receive(new byte[1]);
                }
            }
        }
    }
    

    On my machine output is:

    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    

    Which is what expected. I was testing using Mono from git commit b21a860 on Ubuntu 10.10. About send_so_far, you mentioned: please notice, that call to int Send (byte [] buf) calls internal int Send_nochecks(...) and this in turn calls int Send_internal (socket, buf, offset, size, flags, out nativeError) which is tagged with [MethodImplAttribute (MethodImplOptions.InternalCall)] (so implemented directly in runtime) and uses no send_so_far at all. (As far as I can see, send_so_far is used in AsyncResult, but only in one AsyncResult, therefore it does not have to be zeroed – you can’t call EndSend twice on same AsyncResult.).

    EDIT:

    I have just tested it with async version (i.e. EndSend) and it works properly too. Could you post some piece of problematic code?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im streaming video to my MIDLET. And while it is playing it, after 20
After playing a while with quote/unquote, I wanted to do a trick, but it
After playing around with haskell a bit I stumbled over this function: Prelude Data.Maclaurin>
After playing quite a bit of Bad Company 2 over the last month, I'm
Update: After playing around with this for a few hours, went with a multi-query
I just found /n softwares free Powershell NetCmdlets, and after playing with them I
So i'm trying out MVC after only playing with it some time ago. Need
After installing Monobjc and playing around with the Monobjc Application Project under C# in
I've been playing this flash game and after I'd gotten over the initial ('lol,
Alright, so after a few hours of me playing around to no avail, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.