Use inet4 specifier and add error handling