NodeJS, OpenCV and Streaming Images Using Net Socket

那年仲夏 提交于 2019-12-03 00:39:57

I suspect you're seeing end event while the last bit of data is still buffered.

Try waiting for the close event rather than the end event. I'm not sure about sockets, but in other Node APIs like spawn, the end event is fired early, before related streams are flushed, so there may still be buffered data waiting.

You could avoid managing this yourself by piping. Use fs.createWriteStream() and .pipe() the socket stream to the file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!