Пример #1
0
        public static void ReadAtLeast(this Socket socket, PassiveBuffer readBuffer, int minDataCount, Action <bool, Exception> callback)
        {
            if (readBuffer.Size >= minDataCount)
            {
                callback(true, null);
                return;
            }

            readBuffer.RequireWrite(readBuffer.Available, false, false, out ArraySegment <byte> buffer);
            socket.BeginReceive(buffer.Array, buffer.Offset, buffer.Count, 0, SocketReadCallback,
                                new object[] { socket, readBuffer, minDataCount, callback });
        }
Пример #2
0
 public static void Send(this Socket socket, PassiveBuffer sendBuffer, int count, Action <bool, Exception> callback)
 {
     sendBuffer.RequireRead(count, out ArraySegment <byte> buffer);
     socket.BeginSend(buffer.Array, buffer.Offset, buffer.Count, 0, SocketSendCallback, new object[] { socket, sendBuffer, count, callback });
 }