refactor some sock_utils code into BsimCtrl