Sorry I don't mean to be rude but googling ip socket programming may give you better info rather than waiting for one here (the first link is good). But before start programming sockets, you need to understand the basic TCP/IP protocols (like SMTP) work. I see you are also confused on some basic C functions work like snprintf, so you may need to refresh your C knowledge.

Like you, I tend to learn programming by examples. But the funny thing is sometimes I don't have enough time (deadlines, yes...) to fully understand how things work. As long as I'm sure (by a few trials and errors) when I do this it'll do that, that's enough for now. Just modify some parameters and it works like I want it to. Understanding will come eventually.

My two cents.

Peace always,
<jdenny>