Added error detect. Takes IP and port as inputs