I was creating a server application, which uses socket.write() to send data back to the clients.
Here, I got the problem of managing buffer size. Suppose the connection between server and client broke down, and server was not aware of the problem. So, it keeps writing to the buffer. In such situation, I want to limit the maximum buffer size, so that it can throw errors before it consumes lots of resources.
I know kMaxLength in node_buffer.h controls the size of buffer, but I do not think it's a good idea to change its value via some self-defined methods. Is there any other method to manage the size?
kMaxLength is the limit value for memory allocation, it is much bigger then socket.buffSize
http://nodejs.org/docs/v0.11.5/api/smalloc.html
You can read about socket.buffSize here:
http://nodejs.org/api/net.html#net_socket_buffersize
You can also see socket.bytesRead
, socket.bytesWritten
to control your data transmission.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With