Created
November 24, 2012 09:11
-
-
Save staticcat/4138978 to your computer and use it in GitHub Desktop.
Function to dump what's on a ZmqSocket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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