thamagates / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

File interface to mg_connection #202

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I need to integrate mongoose into an existing code base that pushes data out to 
a file.  The existing code uses a FILE* as a parameter and writes to this file. 
 Therefore, I added the function mg_open() to mongoose, which returns a file 
pointer for the connection (if possible).

The patch is available in my clone:

http://code.google.com/r/arnoutvandecappelle-multiplereads/source/detail?r=62a38
da5f5a3c67a734273df226b4baf894b4e52

Comments are welcome.

Original issue reported on code.google.com by arnout.v...@gmail.com on 8 Nov 2010 at 12:02

GoogleCodeExporter commented 9 years ago
Important detail: the original author of this change is Hans Winderix 
(Septentrio) <hans dot winderix at septentrio com>.

Original comment by arnout.v...@gmail.com on 8 Nov 2010 at 12:11

GoogleCodeExporter commented 9 years ago
This is a nice hack, although one should keep in mind:
  o  it is an error to mix mg_write/mg_printf calls and writing to a file stream
  o  this code won't work on windows, cause win32 runtime does not allow to fdopen sockets

More general approach would be to open a pipe or socketpair, and give away a 
write end. Then, read from a pipe and mg_write is to a client socket. This way 
both problems are solved, but another one emerges: a pipe data buffering (pipe 
size).

Anyways, I don't think this is general enough to go into the main branch.

Original comment by valenok on 29 Nov 2010 at 1:14