PubSub data capturing

I am trying to capture in real time the received pubsub data of a peer under Windows. I know how to redirect standard output of a given process (in C#), but my program gets nothing while the process console window is open. All data are displayed when i close the process window.

Is there any other way to do it? Listening to a specific port or something?

What are you trying that isn’t working? Are you using Process.start?

ipfs pubsub sub <channel> just writes output to stdout. So if you’re capturing stdout, then you should be getting the pubsub data.

@leerspace almost all of the code samples out there are for processes that output text line-by-line.
But PubSub is not doing that, it outputs a continuous flow of data with no line changes, so none of these methods work.
To be able to capture it i had to ReadBlock a StreamReader attached to process stdout.

I hadn’t realized that pubsub discards line endings – or if it doesn’t, I’m not sure how to send line endings using ipfs pubsub pub <channel>.

Even without line breaks, I was going to suggest trying StreamReader's Read or ReadToEnd, but that’s good to know that ReadBlock works.