fill level of receive buffer

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

fill level of receive buffer


I would like to know the number of bytes in the socket-CAN receive buffer.
The thread
did not provide an answer. The function ioctl, which can usually be used to get the size of a file descriptor, returns the following error:

// setting up the receive can buffer
fd_ = socket(PF_CAN, SOCK_RAW, CAN_RAW);
struct ifreq ifr;
strcpy(ifr.ifr_name, can_device_name.c_str());
ioctl(fd_, SIOCGIFINDEX, &ifr)
struct sockaddr_can addr;
addr.can_family =AF_CAN;
addr.can_ifindex = ifr.ifr_ifindex;
if (bind(fd_, (struct sockaddr*)&addr, sizeof(addr)) <0) { // error }

// what is the the size of the receive buffer in bytes?
int n;
err = ioctl(fd_, FIONREAD, &n);

This function returns err=-1 with errno=ENOTTY, which means that "fs is not associated with a character special device."

How can I get the size of the  receive buffer of the CAN socket file descriptor?