Skip to content
This repository has been archived by the owner on May 17, 2018. It is now read-only.

Add SOCK_SEQPACKET support #23

Open
vi opened this issue Dec 28, 2015 · 6 comments
Open

Add SOCK_SEQPACKET support #23

vi opened this issue Dec 28, 2015 · 6 comments

Comments

@vi
Copy link

vi commented Dec 28, 2015

Obviously, sequential packet sockets should support #4 and #5.

They also have listener/connection, unlike datagram sockets.

@sfackler
Copy link
Member

Servo's ipc-channel uses SEQPACKET sockets which might provided some inspiration on the implementation.

The API's probably going to be a bit weird due to the need to indicate packet boundaries.

@vi
Copy link
Author

vi commented Dec 29, 2015

Aren't usual traits Read and Write not enough?

Each write corresponds to one read at the other side. Reading with too small buffer is Err. There can be Ok(0) from read and it's not a failure or EOF.

I.e. existing code can happen to work even if substitute SOCK_STREAM with SOCK_SEQPACKET.

Alternatively reuse part of API from UnixDatagram, possibly extracting common things into traits.

@sfackler
Copy link
Member

Ah, I was expecting SEQPACKET records to be specified via MSG_EOR in sendmsg and recvmsg and be allowed to split across read/write calls, but they apparently behave more like connected datagram sockets: http://stackoverflow.com/questions/3595684/why-do-i-not-see-msg-eor-for-sock-seqpacket-on-linux.

Seems like an API similar to UnixDatagram without the unconnected variants would work then. I would like to make sure that SEQPACKET behavior is roughly consistent betwee Linux, OSX, BSDs, etc though.

@rrichardson
Copy link

rrichardson commented May 22, 2016

Just came here to enter an issue for seqpacket :) Yea, SEQPACKET's API semantics are connection oriented like stream, but datagram oriented. In my testing, on Linux I have found that seqpacket connections support either the send or the sendmsg functions. So it can be treated basically as a stream API, with the understanding that payloads are never sent via multiple messages.

Looking at the lib, we could probably get away with just adding an option or an alternate constructor to UnixStream.

Whether the consensus is to make a UnixSeqpacket struct and factor out the common functionality, I am happy to implement either.

@sfackler
Copy link
Member

I think it'd make more sense as a separate UnixSeqpacket struct for now, but yeah, please do!

@rrichardson
Copy link

I forgot one rather important thing, this PR depends upon rust/libc PR rust-lang/libc#300

Since libc doesn't presently contain SOCK_SEQPACKET

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants