Fix php cli (-S option) inconsistent port parsing

Add port range verification of listening port with -S option for the php cli.
This fixes inconsistent listening port due to unverified cast from long to short
with htons(3).
Fix #53092 - dns_get_record does not return false on dns server failure
Changed based on comments and make its behaviour equal to the Windows version
Added more useful warning messages