Exemplo n.º 1
0
        internal static bool TrySendMessage(IMalockSocket socket, Stream message)
        {
            if (socket == null || message == null)
            {
                return(false);
            }
            MemoryStream ms = (MemoryStream)message;

            return(socket.Send(ms.GetBuffer(), 0, Convert.ToInt32(ms.Position)));
        }
Exemplo n.º 2
0
        public virtual bool Send(byte[] buffer, int ofs, int len)
        {
            IMalockSocket socket = null;

            lock (this.syncobj)
            {
                socket = this.preferred;
            }
            if (socket == null)
            {
                return(false);
            }
            return(socket.Send(buffer, ofs, len));
        }
Exemplo n.º 3
0
 internal static bool TrySendMessage(IMalockSocket socket, MalockMessage message, byte[] buffer, int ofs, int len)
 {
     if (socket == null || message == null)
     {
         return(false);
     }
     using (MemoryStream ms = (MemoryStream)message.Serialize())
     {
         if (buffer != null)
         {
             ms.Write(buffer, ofs, len);
         }
         return(socket.Send(ms.GetBuffer(), 0, Convert.ToInt32(ms.Position)));
     }
 }
Exemplo n.º 4
0
 internal static bool TrySendMessage(IMalockSocket malock, MalockMessage message, ref Exception exception)
 {
     if (malock == null)
     {
         throw new ArgumentNullException("malock");
     }
     if (message == null)
     {
         throw new ArgumentNullException("message");
     }
     using (MemoryStream ms = (MemoryStream)message.Serialize())
     {
         if (!malock.Send(ms.GetBuffer(), 0, unchecked ((int)ms.Position)))
         {
             exception = new InvalidOperationException("The malock send returned results do not match the expected");
             return(false);
         }
     }
     return(true);
 }