improved resource disposal for socket connections