Indirectly, yes Sergey, that address the question, thanks!. You are saying that there is no way to get a file descriptor binded to the socket connection and use it to send characters to a client. That makes me really sad... :(
Is there any other way to do that? I'll try to re-formulate my problem as follows, to make it clearer.
Given a function:
void generate_content(int fd)
that outputs text to the file descriptor fd (for example, an html page) I am looking for a method to extract a file descriptor from an mg_connection (or an mg_server, or both) so that I can use it to force generate_content() to write directly to the client at the other end of a connection.
At the moment, the only workaround I found to solve this problem is to open a local file and pass its fd to generate_content(), so that it writes into the local file. Then, open the file with read permission, read the content and send it to the client with mg_send_data().
Any hints?
Thanks so much!