[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reading data from a file descriptor

From: Jan Synáček
Subject: Reading data from a file descriptor
Date: Sat, 7 Nov 2015 15:52:27 +0100

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);

Jan Synáček

reply via email to

[Prev in Thread] Current Thread [Next in Thread]