Learn more about scanning techniques (for example, about ones Nmap uses) and try to implement some of them.