Hello Guilers,
how do I read data from a file descriptor? I already have an fd required from elsewhere that I need to read data from and actually have no idea how to do that. I read through the documentation on ports, but that didn't help. The fd actually points to a socket.
In C, I have something like this:
const size_t bufsize = 4096;
char buf[bufsize+1];
ssize_t count;
int fd;
fd = require_valid_fd()
count = read(fd, buf, bufsize);
buf[count] = '\0';
printf("read: %s\n", buf);