c# - How to use TransmitFile with HttpListener -


i have http server written using httplistener , want zero-copy technology sending files clients.

is there option use transmitfile respond?

i assume you're referring httpresponse.transmitfile? httplistener doesn't buffer response content, need write directly output stream.

you can use extension method mimic asp.net behavior:

public static void transmitfile(this httplistenerresponse response, string filename) {     using (var filestream = file.openread(filename))     {         response.contentlength64 = filestream.length;         filestream.copyto(response.outputstream);     } } 

Comments

Popular posts from this blog

Linux vanilla kernel on QEMU and networking with eth0 -

rdbms - what exactly the undo information lives in oracle? -

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -