Skip to content
This repository has been archived by the owner. It is now read-only.

added UnixSeqpacket and UnixSeqpacketListener. #25

Open
wants to merge 4 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@rrichardson
Copy link

rrichardson commented May 27, 2016

plus minor refactoring to consolidate into Inner.

This addresses issue #23

This would be much nicer with generic impl specialization :)

UnixStreamListener and UnixSeqpacketListener are 99% alike. In fact, in their implementations they only differ in 3 words, unfortunately, two of those are in return types, so there wasn't a clean way to factor them out, aside from making some sort of UnixSocket trait. So we're stuck with it unless we want to get crazy.

I moved send and recv into Inner which cleaned up some code in UnixStream and UnixDatagram while reducing the amount to duplicate into UnixSeqpacket.

Added a test for basic seqpacket functionality. All of the rest of the tests still pass.

@rrichardson

This comment has been minimized.

Copy link
Author

rrichardson commented May 27, 2016

Depends upon rust-lang/libc#300

src/lib.rs Outdated
@@ -536,13 +717,13 @@ impl IntoRawFd for UnixStream {
/// // close the listener socket
/// drop(listener);
/// ```
pub struct UnixListener {
pub struct UnixStreamListener {

This comment has been minimized.

@sfackler

sfackler May 27, 2016

Member

I think we should probably leave this as UnixListener. It's a bit of an unfortunate naming setup, but that's what the standard library setup has, and it's slated for stabilization.

This comment has been minimized.

@rrichardson

rrichardson May 27, 2016

Author

:(
o.k.

On Fri, May 27, 2016, 12:42 AM Steven Fackler notifications@github.com
wrote:

In src/lib.rs
#25 (comment)
:

@@ -536,13 +717,13 @@ impl IntoRawFd for UnixStream {
/// // close the listener socket
/// drop(listener);
/// ```
-pub struct UnixListener {
+pub struct UnixStreamListener {

I think we should probably leave this as UnixListener. It's a bit of an
unfortunate naming setup, but that's what the standard library setup has,
and it's slated for stabilization.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/rust-lang-nursery/unix-socket/pull/25/files/fcb59380b36d9182b7b83c1db74ef0c9f345674c#r64857039,
or mute the thread
https://github.com/notifications/unsubscribe/AAHlC24C1s3x9VvOxC7H9USyEkFBwTLXks5qFnZOgaJpZM4IoKe0
.

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented May 27, 2016

Yay!

@rrichardson

This comment has been minimized.

Copy link
Author

rrichardson commented May 27, 2016

K. It's now UnixListener. Now it just needs the libc branch merged.

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Jun 2, 2016

Is this still blocked on libc?

@rrichardson

This comment has been minimized.

Copy link
Author

rrichardson commented Jun 2, 2016

Yes. The PR for SEQPACKET was merged but a new version has not been pushed
into crates.io.

On Thu, Jun 2, 2016 at 1:54 AM Steven Fackler notifications@github.com
wrote:

Is this still blocked on libc?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#25 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAHlC2xX5n5NQF0gZR0E3mLpWwxO3wqzks5qHnADgaJpZM4IoKe0
.

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Jun 2, 2016

(ping @alexcrichton)

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jun 4, 2016

"Seqpacket" here seems kinda long but beyond that seems reasonable to me!

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Jun 10, 2016

A new libc release landed, so you should be able to bump the version to 0.2.12 and get things building.

@rrichardson

This comment has been minimized.

Copy link
Author

rrichardson commented Jun 10, 2016

There is another conflict: libc depends on tempdir which depends on rand which depends on libc 0.2.11.
Should we bump rand up to 0.2.12 as well then?

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Jun 10, 2016

Unless it depends on =0.2.11, those should work just fine together 0.2.11 means >= 0.2.11, < 0.3.

@rrichardson

This comment has been minimized.

Copy link
Author

rrichardson commented Jun 10, 2016

I'm trying to sort this out. Rand states that it depends on 0.2, but I'm getting:

error: failed to select a version for `libc` (required by `rand`):
all possible versions conflict with previously selected versions of `libc`
  version 0.2.12 in use by libc v0.2.12
  possible versions to select: 0.2.11

oddly, if I specify I depend on libc = "0.2" instead of "0.2.12" it downloads and compiles 0.2.12.

specifying 0.2.12 states that only 0.2.11 is available.

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Jun 10, 2016

Try a cargo update or deleting Cargo.toml.

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Jun 28, 2016

Looks like this needs a rebase and then it should be ready to go!

@dkl

This comment has been minimized.

Copy link

dkl commented Apr 9, 2018

Hi, I'd like to help out with finishing this. @rrichardson, did you still plan to work on it, or is it ok if I rebase and re-submit the pull request?

Or is it better to directly add to libstd now (seeing #27)?

@rrichardson

This comment has been minimized.

Copy link
Author

rrichardson commented Apr 9, 2018

Wow, I totally forgot about this. I guess rebase and give it a go.
If it makes sense to the libstd maintainers, I'd be happy to help make a PR for that.

@dkl

This comment has been minimized.

Copy link

dkl commented Apr 29, 2018

Hey again, I tried writing an RFC for it (since it's an addition to std): https://github.com/dkl/rust-rfcs/blob/unixsocket-seqpacket/text/0000-unix-socket-seqpacket.md
Does that seem reasonable? Any suggestions before submitting?

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Apr 30, 2018

The API description in the RFC seems reasonable to me, but I don't think a full RFC is required for an addition like this - a PR direct to add the types (as unstable) should be fine!

bors added a commit to rust-lang/rust that referenced this pull request May 7, 2018

Auto merge of #50348 - dkl:unix-seqpacket-socket, r=sfackler
std: Add support for SOCK_SEQPACKET Unix sockets

Hi,

this patch adds support for SOCK_SEQPACKET unix sockets to std::os::unix::net. It is based on @rrichardson's [PR for the old unix-socket crate](rust-lang-nursery/unix-socket#25), but ported to the current libstd, with some more unit tests.

`SOCK_SEQPACKET` support was already mentioned in the [RFC for unix-socket](https://github.com/rust-lang/rfcs/blob/master/text/1479-unix-socket.md). The main idea is to add two new structs:
* `UnixSeqpacketListener` similar to `UnixListener` with bind() and accept() for the server-side.
* `UnixSeqpacket` similar to `UnixDatagram` but only with connect(), no bind(), for the client-side. This provides send() and recv() methods, but not send_to()/recv_from() since it's connection-oriented, and also no io::Read/io::Write, due to SOCK_SEQPACKET reads/writes transferring one message at a time, as opposed to being a byte stream.

Without this feature in std, programs have to use plain unsafe libc directly to open the socket, and then possibly use the FromRawFd constructors of UnixDatagram/UnixListener and stick to the  methods that make sense for SOCK_SEQPACKET.

I'm not sure how to handle the stability attributes for this - it's unstable, but can it be assigned to the unix_socket feature, or does it need a new feature name and tracking issue?

bors added a commit to rust-lang/rust that referenced this pull request May 9, 2018

Auto merge of #50348 - dkl:unix-seqpacket-socket, r=sfackler
std: Add support for SOCK_SEQPACKET Unix sockets

Hi,

this patch adds support for SOCK_SEQPACKET unix sockets to std::os::unix::net. It is based on @rrichardson's [PR for the old unix-socket crate](rust-lang-nursery/unix-socket#25), but ported to the current libstd, with some more unit tests.

`SOCK_SEQPACKET` support was already mentioned in the [RFC for unix-socket](https://github.com/rust-lang/rfcs/blob/master/text/1479-unix-socket.md). The main idea is to add two new structs:
* `UnixSeqpacketListener` similar to `UnixListener` with bind() and accept() for the server-side.
* `UnixSeqpacket` similar to `UnixDatagram` but only with connect(), no bind(), for the client-side. This provides send() and recv() methods, but not send_to()/recv_from() since it's connection-oriented, and also no io::Read/io::Write, due to SOCK_SEQPACKET reads/writes transferring one message at a time, as opposed to being a byte stream.

Without this feature in std, programs have to use plain unsafe libc directly to open the socket, and then possibly use the FromRawFd constructors of UnixDatagram/UnixListener and stick to the  methods that make sense for SOCK_SEQPACKET.

I'm not sure how to handle the stability attributes for this - it's unstable, but can it be assigned to the unix_socket feature, or does it need a new feature name and tracking issue?
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.