adds closure to socket stream