/**
* Deactivate socket, wait to complete sending all unfinished data, then close connection.
*/
public function end()
{
if ($this->closed) {
return;
}
$that = $this;
$this->buffer->on('end', function () use($that) {
$that->close();
});
$this->buffer->end();
}