public virtual void SendAsync(AbstractMessage message)
 {
     this.sendDone.WaitOne();
     byte[] buffer = message.GetEnvelope();
     Trace.WriteLine(string.Format("Sending asynch message {0} len {1}", message.MessageUID, message.MessageLength));
     this.socket.BeginSend(buffer, this, SendCallback);
 }
 /// <summary>
 /// Send a buffer. It's a synchronous operation. The previous send has to be completed.
 /// You can define a timeout on the previous send and skip this one in case of time out.
 /// </summary>
 /// <param name="message">The message to send</param>
 /// <param name="previousSendTimeout">Timeout on the previous send in ms</param>
 /// <returns>True if the message has been sent, otherwise false</returns>
 internal bool SendMessage(AbstractMessage message, int previousSendTimeout)
 {
     byte[] buffer = message.GetEnvelope();
     Trace.WriteLine(string.Format("Sending message {0} len {1}", message.MessageUID, message.MessageLength));
     bool r = SendBuffer(this, buffer, previousSendTimeout);
     return r;
 }