()
| 59 | next(); |
| 60 | |
| 61 | function next() { |
| 62 | if (socket.destroyed) { |
| 63 | console.log('socket was destroyed early, data left to write:', |
| 64 | array.join('').length); |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | const chunk = array.shift(); |
| 69 | |
| 70 | if (chunk) { |
| 71 | console.log('writing chunk of size', chunk.length); |
| 72 | socket.write(chunk, next); |
| 73 | } else { |
| 74 | socket.end(); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | function test1() { |