Example #1
0
        unsafe int Send(byte [] buffer, int offset, int len)
        {
            if (secure || no_libc)
            {
                requestBroker.Write(requestId, buffer, offset, len);
                return(len);
            }

            int total = 0;

            while (total < len)
            {
                fixed(byte *ptr = buffer)
                {
                    // 0x4000 no sigpipe
                    int n = send((int)socket, ptr + total, (IntPtr)(len - total), 0x4000);

                    if (n >= 0)
                    {
                        total += n;
                    }
                    else if (Marshal.GetLastWin32Error() != 4 /* EINTR */)
                    {
                        throw new IOException();
                    }
                }
            }

            return(total);
        }
        int Send(byte [] buffer, int offset, int len)
        {
#if MONO
            if (secure || no_libc)
            {
#endif
            requestBroker.Write(requestId, buffer, offset, len);
            return(len);

#if MONO
        }

        int total = 0;
        while (total < len)
        {
            fixed(byte *ptr = buffer)
            {
                // 0x4000 no sigpipe
                int n = send(socket, ptr + total, (IntPtr)(len - total), (IntPtr)0x4000);

                if (n >= 0)
                {
                    total += n;
                }
                else
                {
                    throw new IOException();
                }
            }
        }

        return(total);
#endif
        }