Beej's guide has been a timeless classic in network programming.
http://beej.us/guide/bgnet/Beej's guide is what The C Programming Language (K&R) is for C, what Donald Knuth's TOACP is for algorithms, what MIT's SICP (the wizard book) is for language and what Compilers: Principals, Techniques and Tools (The dragon book) is fro compiler theory.
Anyways, if you want to implement a traditional pinger similar to the ping command line tool, you'll have to send ICMP packets. Standard sockets typically only allow for the sending of data of TCP or UDP packets (that the kernel creates for you) that sit on top of the IP protocol. ICMP like IP is an OSI layer 3 protocol that sits directly on a layer 2 protocol (typically ethernet frames).
in *nix you'll need to open a raw socket with the ICMP proto flag. The following should be a push in the right direction.
http://www.kernel.org/doc/man-pages/onl ... cmp.7.htmlhttp://www.kernel.org/doc/man-pages/onl ... raw.7.html
"If art interprets our dreams, the computer executes them in the guise of programs!" - SICP

“If at first, the idea is not absurd, then there is no hope for it” - Albert Einstein