I defined ip_port to be unsigned precisely so as not to have to do this kind of casting.