Closed talex5 closed 1 year ago
Having tried this out for a bit, this API is a little annoying because we also need unix equivalents to Net.run_server
, etc. So I think it might be better to make the main Eio types polymorphic instead.
I've removed the FD passing bits for now and put them at https://github.com/talex5/eio/tree/fd-passing, which I'll submit separately once this is merged. So this PR is just adding a skeleton Eio_unix.Net
and sorting out the stream/datagram confusion now, which should make it easier to review.
I've pushed a couple of minor changes:
Unix
tag for datagrams, since it's the same file either way, and therefore the same address. I think Windows named pipes should have their own tag if we want them, but that should be a separate issue.Eio_unix.Net.import_socket_datagram
to match import_socket_stream
.If there are no objections I'll merge this tomorrow, so I can then submit the FD-passing PR.
One implication of this change is that Eio.Net.accept_fork
and other connection handlers now must implement close
(whereas previously it was just a Flow.two_way).
(For reference, this is the diff I applied to bring other libraries uptodate with this change https://github.com/avsm/eeww/commit/dfdd8f248b249254b63bc5f18f8ab172ec94ca0e)
Good point. At the moment, accept_fork
always closes the flow when the handler finishes, so if you close it manually then that will fail, which is why we didn't have close here before. Perhaps we should revert the addition of close here.
It would be cleaner to just pass a Flow.two_way I think, and leave closing to the connection handler.
Eio_unix.Net
module and move network-related items fromEio_unix
to there.Eio_unix.socketpair
withEio_unix.Net.socketpair_{stream,datagram}
. Previously, it took a type argument (stream or datagram), but always returned astream_socket
.eio.unix
so they can be shared.getnameinfo
ineio.unix
to share it by default.Eio_linux.Low_level.send_msg
no longer throws away the number of bytes sent.close
to all socket types.send
is now optional, for unconnected datagram sockets.send
now takes a iovec, not just a single buffer. The stream API allows this and we tested it for datagrams using that API due to the previous type confusion.Unix_datagram
socket address type for completeness.send_msg
andrecv_msg
stubs to Eio_posix. This avoids converting to bytes, and will be useful to add FD passing later.I was planning to include FD passing in this FD, but it got too long so I've split that out for later.
Fixes #342.