Code Monkey home page Code Monkey logo

tokio-uds's Issues

Why no FromRawFd?

How do I use pre-opened (for example by inetd) or received from another UNIX socket file descriptor in tokio-uds?

Method for getting credentials of the peer

I'd be useful to have a method for getting peer credentials. I suggest get_peer_cred(&self) -> UCred.

I need this now, so I'll now impl it via extension trait (by getting RawFd) but I plan to submit a proper PR later.

ucred problems on openbsd

Hi! In trying to compile pijul for openbsd 6.3-current, rustc 1.25.0,, I get the following error:

Compiling tokio-uds v0.1.7
error[E0425]: cannot find function `get_peer_cred` in module `ucred`
   --> /home/patrick/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-uds-0.1.7/src/lib.rs:310:16
    |
310 |         ucred::get_peer_cred(self)
    |                ^^^^^^^^^^^^^ not found in `ucred`

error: aborting due to previous error

error: Could not compile `tokio-uds`.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `pijul v0.9.0`, intermediate artifacts can be found at `/tmp/cargo-install.DADQlJvS3dW6`

Caused by:
  build failed

The use of `io::Result` instead of `futures::Async`

I noticed that, contrary to my unsubstantiated expectations, thatUnixDatagram::{send, recv} return io::Result, instead of turningWouldBlock errors into futures::Async::NotReady.

It's not clear to me what result types are approriate for each layer -- I'd have assumed io::Result in mio, and public, but primitive methods (like send and recv) in tokio-based APIs would use some Async type variant.

I'm asking not due to API usability issues, but since I am trying using tokio-uds as a blueprint for zmq-tokio.

This is really one of the biggest hurdles for me: that there's no blueprint I'm totally confident in having the API types right, and no docs explaining how it should be done, and why.

If I reach sufficient understanding, I can maybe come up with a documentation patch for tokio-core that explains the design ideas behind that, but right now I'm at quite a loss.

Compatibility with tokio crate (not tokio-core)

This crate still requires handle for UnixStream, UnixStream and UnixDatagram constructors (connect, bind, pair...)

It should be changed to support tokio crate and the new style of writing Tokio-based services.

Example of reading from a Unix socket

First, I am a Rust newbie...

I am trying to read data from a Unix socket, but I am failing:

extern crate futures;
extern crate tokio_core;
extern crate tokio_signal;
extern crate tokio_uds;

use std::io::Read;

use futures::{Future, Async, Poll};
use tokio_core::reactor::Core;
use tokio_uds::{UnixListener, UnixStream};

struct Echo {
    listener: UnixListener,
}

impl Future for Echo {
    type Item = ();
    type Error = ();

    fn poll(&mut self) -> Poll<(), ()> {
        loop {
            if let Async::Ready(()) = self.listener.poll_read() {
                println!("New Connection");

                let (mut stream, _) = self.listener.accept().unwrap();
                let mut buffer = Vec::new();
                stream.read_to_end(&mut buffer);
                println!("{:?}", buffer);
            }
        }
    }
}

fn main() {
    let mut core = Core::new().unwrap();
    let handle = core.handle();

    let listener = UnixListener::bind("/var/run/hello.sock", &handle).unwrap();

    core.run(Echo {listener: listener}).unwrap()
}

Can somebody provide an example of howto get this working, please? Thanks!

Doesn't build on android target

error[E0425]: cannot find function get_peer_cred in module ucred
--> /home/andy/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-uds-0.1.6/src/lib.rs:288:16
|
288 | ucred::get_peer_cred(self)
| ^^^^^^^^^^^^^ not found in ucred

error: aborting due to previous error

Sending and receiving file descriptors

Hi, I would like to send/receive file descriptors (unix sockets). I searched the docs but did not find anything, is it possible to do that right now?

Release new version with from_listener method

Hello, I need to use UnixListener::from_listener() method which is present in unreleased version of the library. Can you release 0.1.2 with that method included? If not, what is needed for release? Can I/do you need help with that?

I'm going to clone this repo for now but I'd like to use package from crates.io.

Thank you!

Use with /dev/net/tun

To add a new TUN/TAP device, you have to open /dev/net/tun, configure it with ioctl then read/select it like a normal fd. Would it be appropriate for use with UnixDatagram? If so, did you consider adding impl FromRawFd for UnixDatagram?

UnixStream::connect does not return a future

From the documentation:

The returned future will resolve once the stream is successfully connected.

Maybe I'm misunderstanding something, but UnixStream::connect returns Result<UnixStream>, not a future.

A short example would be really helpful here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.