Feb 23, 2021 16:51
@sehe How would you pass an async_pipe object to another process?
Feb 23, 2021 02:51
@sehe async_pipe doesn't do what I want from both ends, anyways. Client gets a "file already exists" error when trying to construct an async_pipe with the name given to it from the server.
Feb 19, 2021 04:03
er, I should say "support for both named and anonymous pipes on windows + the equivalent on linux"
Feb 19, 2021 04:00
@sehe This is where the terminology differences hurt. I see "pipes" and I think "the equivalent of both named and anonymous pipes on windows"
Feb 19, 2021 03:59
@sehe Thank you!
Feb 19, 2021 03:57
@sehe Now that you mention it, someone else said something similar. I don't know if Windows supports similar behavior. I will look into that.
Feb 19, 2021 03:57
Perhaps you're right, though.
Feb 19, 2021 03:57
@sehe I like doing things in "standard" ways but at the same time some conventions are bad.
Feb 19, 2021 03:56
@sehe No, I tried it on windows first.
Feb 19, 2021 03:54
@sehe Doing IPC through stdout/stdin just seems so weird to me. And prone to issues; any code anywhere in the program can write to stdout or read from stdin at any time (although the latter is admittedly unlikely).
Feb 19, 2021 03:52
@sehe I spent what coding time I had since posting the question adjusting my code with the conditional compilation stuff I mentioned above. It is compiling now but giving me runtime errors I haven't been able to diagnose yet. So I don't know for sure yet, but I expect it will work based on what I know of FIFO (and async_pipe wraps FIFO, does it not?)
Feb 19, 2021 03:37
Some kind of conditional compilation + typedef magic, where I use async_pipe on linux and stream_handle on Windows seems like my next-likeliest option, but the stream_handle is giving me the issue I described in my question.
Feb 19, 2021 03:35
I thought boost::process::async_pipe was what I wanted, but it didn't work at all the way I wanted on Windows.
Feb 19, 2021 03:35
So to level set, what I want is:
* FIFO on linux
* Named Pipes on Windows
Wrapped up in a cross-platform way, preferably using native async APIs (e.g. overlapped I/O APIs on Windows)
Feb 19, 2021 03:30
@sehe Right, it's more "native" now. Unix Domain Sockets are my next point of investigation, but I'm more wary of them for backwards compatibility purposes. Unfortunately I think some of my ultimate end users are still on older versions of Windows.
Feb 19, 2021 03:23
@sehe Naturally. That's what tests are for, right :troll:
Feb 19, 2021 03:19
Named Pipes have been around in Windows a long time; since way before Windows brought Unix Domain Sockets over to their OS, which I think was 2017.
Feb 19, 2021 03:19
@sehe Ah, I didn't realize that the Unix name for domain sockets was "named pipes." Yes, I am talking about the FIFO equivalent on Windows.
Feb 19, 2021 03:18
@sehe I will look into the preconditions for stream_handle when I get a chance.
Feb 19, 2021 03:17
@sehe I'm not sure descriptors are at play; this is Windows.
Feb 19, 2021 03:11
As my example code implies, I want to use named pipes for IPC. Typical IPC with named pipes (on Windows, at least) involves a "server" and a "client" which use different APIs; the "server" creates the named pipe and then waits for a connection from a client. The "client" connects to an already extant named pipe. This is the kind of behavior I'm looking for (a parent process spawning a child process) and is essentially what my code in this question does using stream_handles. And it mostly works! Except for the read on the server side.
Feb 19, 2021 03:11
Also, async_read_some is not swallowing errors. Perhaps not, but when I try to Peek at the contents of the pipe while waiting for my async read operation to complete, I get a "pipe closed" error and my async read operation times out before completing or giving me any error.
Feb 19, 2021 03:11
@sehe async_pipe ... saves you all the trouble of setting up the pipes This was part of the problem, I think. It sets the pipes up to be used a certain way, which was not the way I wanted. I looked at the code, and it does not match any of the examples of how to set up named pipes in Windows that I could find. There is also no way in the async_pipe API to distinguish between read-only access, write-only access, or duplex acces; not to mention server vs. client. I think it was designed to be used in a very specific way, and that way is not the way I wanted.
Feb 19, 2021 03:11
Hey sehe, thanks for stopping by. All the code in this question is using boost::asio::windows::stream_handle and calling the async_*_some APIs. I understand the confusion, since I included the async_pipe.hpp header (will edit that out) but you will note that I am not actually using them in the code (I was using them in place of stream_handle in my first try, but they didn't work at all). What I am trying to achieve is use named pipes asynchronously on Windows (and eventually Unix) without writing the low-level code myself. boost::asio is the first thing I am trying.
Feb 19, 2021 03:11
I suspect that async_read_some is swallowing errors. When I try to peek at the pipe from another thread while waiting for the read to time out, I get "pipe closed" errors. But async_read_some claims that it will surface any errors it gets from the APIs. Why isn't it telling me that the pipe is closed? Under the hypothesis that maybe the synchronous API would give me the errors, I wrote the code in my "answer" and then it turned out that code worked, which didn't get me any closer to finding out why the async API isn't working.
 

Lounge<C++>

Today we're daydreaming about C++26 reflection
Jan 12, 2021 18:50
Would also love to hear any thoughts or opinions y'all may have, but if you just want to link a blog post that works too.
Jan 12, 2021 18:43
Do y'all know of any good blog posts summarizing the tradeoffs of using UNIX Domain Sockets vs Named Pipes for IPC?
Jan 11, 2021 22:32
@JerryCoffin I'm curious what features you see as missing at this point. Replies seemed like the main one to me.
Jan 11, 2021 22:15
@JerryCoffin 😂
Jan 11, 2021 21:14
Did y'all see that Discord finally got inline replies? Now we just need them in Slack.
Jan 11, 2021 21:13
Well, the level of bitterness I detected seemed pretty reasonable given the circumstances 😆
Jan 11, 2021 21:13
I was looking into some boost::asio stuff and realized the answer I was reading was from you. Clicked on your profile and saw it.
Jan 11, 2021 21:13
Yup.
Jan 11, 2021 21:12
I only found out today 😂
Jan 11, 2021 21:11
I'm really sad that all your old ones were lost.
Jan 11, 2021 21:11
@sehe do you still do live coding streams anywhere?
Jan 11, 2021 21:11
My personal experience with writing microservices from the get-go is that it is a disaster. But YMMV.
Jan 11, 2021 21:10
What I have read about microservices is that the best route to them is to first write a monolith, and then refactor bits of it into separate services as necessary.
Jan 11, 2019 23:21
Good to see y'all again.
Jan 11, 2019 23:21
Hi. :)
Jan 11, 2019 23:15
Since I have been there before?
Jan 11, 2019 23:15
I don't have discord installed right now... but if I log in to my discord account I should see the lounge channel, right?
Jan 11, 2019 23:10
:(
Jan 11, 2019 23:10
> last message 266d ago
last seen 238d ago
Jan 11, 2019 23:09
Hey @R. Martinho Fernandes your blog is down so I can't quote it in arguments with other devs about the Rule of Zero.
Mar 9, 2018 20:14
@sehe lol. Why not just dive right in to some gnarly business logic while you're learning C++?
Feb 14, 2018 19:04
@sehe Thanks again!
Feb 14, 2018 18:53
But I can't find it in the docs anywhere.
Feb 14, 2018 18:53
@sehe Dang, I knew it was there.