GitXplorerGitXplorer
d

tokio-seqpacket-rs

public
15 stars
13 forks
2 issues

Commits

List of commits on branch main.
Verified
360d90408cde60621e06b959bc181e7ffa73f15d

Merge pull request #26 from asomers/patch-1

dde-vri-es committed a month ago
Verified
25739d367796d6394cf5be73d45a49cec62b593f

Update FreeBSD CI image

aasomers committed a month ago
Unverified
34eafff85eab9f0b7a8bc83ee45218f82d877895

Bump version to 0.8.0.

dde-vri-es committed 2 months ago
Verified
b260d4ee9a097ea9363555fe1603b05fcc5d0333

Merge pull request #25 from vi/abstract_zero_byte

dde-vri-es committed 2 months ago
Unverified
46f935d78e26ade76131db7c35e59b0a677bcc58

Update CHANGELOG.md

dde-vri-es committed 2 months ago
Unverified
f7d71081fed1ed4d31d6704f0848920cf46c6b72

Preserve trailing null bytes in abstract paths with `local_addr()`.

dde-vri-es committed 2 months ago

README

The README file for this repository.

Docs.rs Tests

tokio-seqpacket

Unix seqpacket sockets for tokio.

Seqpacket sockets combine a number of useful properties:

  • They are connection oriented.
  • They guarantee in-order message delivery.
  • They provide datagrams with well-defined semantics for passing along file descriptors.

These properties make seqpacket sockets very well suited for local servers that need to pass file-descriptors around with their clients.

You can create a UnixSeqpacketListener to start accepting connections, or create a UnixSeqpacket to connect to a listening socket. You can also create a pair of connected sockets with UnixSeqpacket::pair().

Passing file descriptors and other ancillary data.

You can use send_vectored_with_ancillary and recv_vectored_with_ancillary to send and receive ancillary data. This can be used to pass file descriptors and unix credentials over sockets.

&self versus &mut self

Seqpacket sockets have well-defined semantics when sending or receiving on the same socket from different threads. Although the order is not guaranteed in that scenario, each datagram will be delivered intact. Since tokio 0.3, it is also possible for multiple tasks to await the same file descriptor. As such, all I/O functions now take &self instead of &mut self, and the split() API has been deprecated.

Example

use tokio_seqpacket::UnixSeqpacket;

let mut socket = UnixSeqpacket::connect("/run/foo.sock").await?;
socket.send(b"Hello!").await?;

let mut buffer = [0u8; 128];
let len = socket.recv(&mut buffer).await?;
println!("{}", String::from_utf8_lossy(&buffer[..len]));