[Ur] socket detaching

Sergey Mironov grrwlf at gmail.com
Fri Aug 1 03:47:20 EDT 2014


Hi, Adam. Since you have published your file-serving extension, I'd
like to share my old code for solving similar task.

The idea is to be able to pickpocket the client-connection socket from
the urweb and pass it to some standalone application which would use
it to serve large file. I am using it to send firmware tarballs
(approx 20-50 Mb in size) to the clients.

Here is how it works in more details:
1. The Ur/Web server sets the 'sock' field of the uw_context (see the patch)
2. The program calls the detachSocket function which extracts this
field and prevents Ur/Web from writing anything to this socket.
3. The client program starts new process (via my urweb-callback FFI
library) and passes the socket to it via command line (UNIX layer
makes sure that child processes inherit opened handles correctly)
4. The child process does it job to sending it's content to client

That's it. I'm not asking you to include this modification into the
Ur/Web, just want to share the approach.

Regards,
Sergey

Demo - https://github.com/grwlf/urweb-detach
Patch - https://github.com/grwlf/urweb-detach/blob/master/1_of_1_Introduce__Detach__mechanism_.patch
(and in attachment)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1_of_1_Introduce__Detach__mechanism_.patch
Type: text/x-patch
Size: 8008 bytes
Desc: not available
URL: <http://www.impredicative.com/pipermail/ur/attachments/20140801/a83dd792/attachment.bin>


More information about the Ur mailing list