Page 1 of 1

Why does VLC use file descriptor in IO?

Posted: 13 May 2011 11:44
by haiying7
Hi,

I notice that VLC uses net_Write() to write data to a file descriptor in "io.c"(src/network/), and then, read file descriptor line by line. Why not just read data from a buffer directly? What is the meaning of file descriptor here?

THX.

Re: Why does VLC use file descriptor in IO?

Posted: 13 May 2011 15:12
by RĂ©mi Denis-Courmont
There are no standard ways to do buffered and non-blocking I/O on sockets (fdopen() is not non-blocking and does not work with Winsock).

You are right that net_Gets() implementation makes a lot of system calls, which is suboptimal. But in most performance-critical code paths, net_Gets() is anyway not used.