adds closure on socket connect