lib/connectors/hybrid/tcpsocket.js
function(socket, data, offset) {
  var blen = socket.packageSize - socket.packageOffset;
  var dlen = data.length - offset;
  var len = Math.min(blen, dlen);
  var dend = offset + len;

  data.copy(socket.packageBuffer, socket.packageOffset, offset, dend);

  socket.packageOffset += len;

  if(socket.packageOffset === socket.packageSize) {
    // if all the package finished
    var buffer = socket.packageBuffer;
    socket.emit('message', buffer);
    reset(socket);
  }

  return dend;
}
function(socket, data, offset) {
  var blen = socket.packageSize - socket.packageOffset;
  var dlen = data.length - offset;
  var len = Math.min(blen, dlen);
  var dend = offset + len;

  data.copy(socket.packageBuffer, socket.packageOffset, offset, dend);

  socket.packageOffset += len;

  if(socket.packageOffset === socket.packageSize) {
    // if all the package finished
    var buffer = socket.packageBuffer;
    socket.emit('message', buffer);
    reset(socket);
  }

  return dend;
}
function ( socket , data , offset ) { var blen = socket . packageSize - socket . packageOffset ; var dlen = data . length - offset ; var len = Math . min ( blen , dlen ) ; var dend = offset + len ; data . copy ( socket . packageBuffer , socket . packageOffset , offset , dend ) ; socket . packageOffset += len ; if ( socket . packageOffset === socket . packageSize ) { // if all the package finished var buffer = socket . packageBuffer ; socket . emit ( 'message' , buffer ) ; reset ( socket ) ; } return dend ; }
Read body segment from data buffer to socket.packageBuffer;

@param  {Object} socket Socket instance
@param  {Object} data   Buffer instance
@param  {Number} offset offset read star from data
@return {Number}        new offset of data after read
Read body segment from data buffer to socket . packageBuffer ;