Telnet implementation In C for checking whether given IP and PORT is reachable or not?

Telnet implementation In C for checking whether given IP and PORT is reachable or not, It should return the reachability status only and should not allow user to see a telnet session upon successful connection ?