1

I want to receive multiple messages from a SctpStream in a single system call. My goal is to know the number of bytes received every time I make a receive call.

The Linux socket function recvmmsg returns multiple messages:

int recvmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen,
                unsigned int flags, struct timespec *timeout);
DESCRIPTION         
The recvmmsg() system call is an extension of recvmsg(2) that allows
the caller to receive multiple messages from a socket using a single
system call. ...

I tried reading the socket buffer but it always returns 0 bytes. Does this mean that EOF has been reached? I tried sending different number of packets and the buffer is also very large. Still I always get 0 as the number of bytes returned. I am receiving the packets; transmission is not a problem here.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
JRD
  • 37
  • 2
  • How rust could do anymore that what OS provide ??? use https://rust-num.github.io/num/libc/fn.recvmmsg.html – Stargateur Nov 20 '18 at 17:34
  • @Stargateur Rust has many abstractions on top of what the OS provides. It's difficult to tell exactly what OP wants to do, but possibly there would be some wrapped version of that specific system call with nice Rust semantics. The [nix crate](https://crates.io/crates/nix) is one such example (although it doesn't have anything for `recvmmsg` specifically). – Shepmaster Nov 20 '18 at 17:57
  • @Shepmaster Yes, of course, what I want to say is that linux AFAIK, don't provide alternative, and that if a lib want to implement this feature it can only use this API. However I agree question is not clear. If SctpStream crate doesn't use it then the answer is "there is not", dev it yourself that should be simple to add. – Stargateur Nov 20 '18 at 18:40
  • I wonder if its exclusion from the nix crate has to do with the required "_GNU_SOURCE" feature test macro (when in C-land). (edit: bad link) – laslowh May 23 '19 at 15:12

0 Answers0