I am relatively new to the C language, but I'm a very fast learner. I'm looking to do some basic network programming in C but I'm not sure how to start. Could anyone point me to a good guide or tutorial for C Network Programming?
Do you want to program in *nix or windows? AFAIK there are some subtle differences between the *nix and windows implementations of sockets (which you'll probably need to use).
Anyway, for winsock programming I found this FAQ VERY useful. It's more of a manual than a FAQ imo.
Berkeley Sockets
This is a reasonable guide to Berkeley sockets, which is pretty much what every OS uses for the network API.
I learned using "Unix Network Programming, Volume 1: The Sockets Networking API" which is an excellent book that not only shows you how to use it, but what happens when you use it, and why you might choose one usage over another.
Look up "C TCP/IP example" for some example programs to whet your whistle. Also pay attention to your particular compiler's libraries - there are slight differences in how a the Berkeley API is implemented, which might bite you.
Googling for "C sockets" yields a few tutorials that seem OK, such as these:
http://www.linuxhowtos.org/C_C++/socket.htm
http://beej.us/guide/bgnet/
Only a couple of functions are really necessary for your first networking program. Once you know what they are (WSAStartup first on Win32, socket to create a socket, bind/listen/accept or connect and close, etc.; see the tutorials) you can look them up on your platform reference (i.e. MSDN or man pages)
And download a copy of Netcat, "The Swiss Army Knife of TCP/IP," a telnet-like program that will help you a lot with your testing and debugging.
I found Linux Socket Programming by Example a very helpful read when I was learning. Depending on the OS you're using you may also find it a good read.
If you're doing Windows sockets programming, make sure you pay careful attention to The Windows Sockets Lame List. It kept me from making stupid mistakes many times.
for Unix/Linux, I would recommend unix network programming by Richard Stevens.
I've worked in networking programming for the last 6 years.
The best start is with Beginning Linux Programming-WROX-Neil Mathew and Richard Stones,
chapter 15 I think,...and Richard Stevens's books will be bibles for you. A set of 7 books:
- Advanced programming in Unix environment,
- Unix net work programming volume 1/2/3 (vol 1 is enough for you),
- TCP/IP illustrated volume 1/2/3, and
- Socket programing by example.
These are the best books according to my experience.