难道只能在 socket.on("data",function(data){})这样的事件触发回调函数里面才能用吗?
如果我想写一个服务器,把所有的 socket 都显示的放在数据结构里面,然后进行 read write ,这样如何做?
1
foxwoods 2015-12-14 13:07:43 +08:00
去 读 [stream 的 API 文档]( https://nodejs.org/api/stream.html)
> Readable streams have two "modes": a flowing mode and a paused mode. > When in flowing mode, data is read from the underlying system and provided to > your program as fast as possible. In paused mode, you must explicitly call > stream.read() to get chunks of data out. Streams start out in paused mode. #RTFM |