Skip to content

Instantly share code, notes, and snippets.

@staticcat
Created November 24, 2012 09:11
Show Gist options
  • Save staticcat/4138978 to your computer and use it in GitHub Desktop.
Save staticcat/4138978 to your computer and use it in GitHub Desktop.
Function to dump what's on a ZmqSocket
public static void Dump(ZmqSocket socket, Encoding encoding)
{
if (socket == null) {
throw new ArgumentNullException("socket");
}
Console.WriteLine(new String('-', 38));
ZmqMessage message = socket.ReceiveMessage();
foreach (var frame in message)
{
Console.Write("[{0:d3}] ", frame.BufferSize);
if (frame.BufferSize == 5 && frame.Buffer[0] == 0)
Console.WriteLine("{0}", BitConverter.ToString(frame.Buffer).Replace("-", string.Empty));
else
Console.WriteLine("{0}", encoding.GetString(frame.Buffer));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment