Safe parsing for port