fix a bug in the open by port number function