I want to write a client/server app - let's say "TCP Chat". I have not too much knowledge about how protocols work. What's your choice for a beginner's book in developing network apps - both on how protocols work and how to write good code?
views:
180answers:
5Many of the books by W. Richard Stevens are very good for the fundamentals of TCP/IP communications.
The books are UNIX-centric, but they do address the lowest level APIs and describe the protocols too.
I liked TCP/IP Illustrated, Volume 1: the Protocols (also UNP Book) for an explanation of how the protocols work.
The answer to "how to write good code" depends on the O/S and/or on the programming language.
I'm going to disregard the actual technology portion of TCP/IP and networking. I had some great networking courses in college, and I'm assuming - from the sound of things - that you're working on some homework type question. For the theory or networks, you probably can't go too far wrong with too many of the books on Barnes & Noble or Amazon.
I'm guessing however that you aren't interested in theory - although I would highly recommend that you do read some theory. It goes without saying that having an appreciation for why IP became as prevalent as it did will pay huge dividends once you get into the thick of it. For your actual question - writing a client / server app - I think this depends highly on your language of choice. If you're using VB or C#, I would highly recommend saving your money and simply using MSDN - the following are a good intro to writing some very basic TCP/IP based programs:
(For those who will inevitably criticize my choices, I picked the easiest starting point for TCP/IP communication. Later on one can always get into the lower level classes and / or asynchronous communication)
Good luck!
As many others already have, I would also recommend a book by Stevens, but I would recommend "Unix Network Programming, Vol. 1". It covers the fundamental concepts as well as both basic and advanced use of TCP, UDP and SCTP.
The book also covers different application structures such as iterative, threaded etc. in a very comprehensive way. I highly recommend this book.