Pre-RFC: Adding SOCK_SEQPACKET Unix sockets to std


#1

Hi,

the standard library already includes support for stream and datagram Unix domain sockets, but the seqpacket ones are missing. There already is an open PR for that in the old unix-socket crate by @rrichardson, but it turns out that unix-socket was moved into libstd and should be added there now.

So now I’ve basically ported it to the current libstd, and added some additional unit tests. But how to proceed from here? Should I try writing an RFC for it? There already was an RFC for unix-socket, but I guess adding the seqpacket stuff now is a separate deal.

The main idea is to add the two new structs:

  • server: UnixSeqpacketListener similar to UnixListener, with bind() and accept().
  • client: UnixSeqpacket similar to UnixDatagram, but only with connect(), no bind().

Open issues (as far as I can tell):

  • As was already noted in the unix-socket PR, this essentially adds some duplicate code, since the seqpacket structs are so similar to the existing ones. But I don’t know how to refactor it (tried with a common trait and couldn’t get it working). Maybe UnixDatagram/UnixListener should have special constructors for seqpacket, or ones that allow specifying the socket type? But of course that doesn’t match the pattern of one struct per socket type.
  • libstd requires stability attributes, so I added unstable and issue = "0" since there is no tracking issue yet.

By the way, I’ve been building with ./x.py test -i --stage 1 src/libstd and some variations of that, but it takes about 30min here, which makes for a painfully slow edit/compile/test cycle. Is there a faster way?

I’d appreciate any feedback or tips, thanks!