Java Network / Socket programming tutorial

Here is a nice sample chapter from Java Network Programing. There's also some other parts available here, and also sample sources are available.

If you'd decide to buy this book, I'd say these chapters are enough for now:

  • Chapter 2. Basic Network Concepts
  • Chapter 3. Basic Web Concepts
  • Chapter 4. Java I/O
  • Chapter 5. Threads
  • Chapter 6. Looking Up Internet Addresses
  • Chapter 7. URIs and URLs
  • Chapter 9. Sockets for Clients
  • Chapter 10. Sockets for Servers

Don't bother about NIO yet; it's quite advanced.

In addition, I don't know if I'm mixing things now but to my understanding can the multithreading paradigm also be applied to the network / socket programming.

Yes, indeed it's a very important aspect. You'll find out why once you've read the sample chapter.

Have fun!


I've only read the C version of this book, but likely Java version is going to be equally short and good: Calvert and Donahoo's TCP/IP Sockets in Java: Practical Guide for Programmers. Even if you learned socket programming in C, you could probably adapt to Java's implementation fairly quickly.

alt text


from my experience and in my opinion, when you want to learn socket programming at the level of abstraction provided by the Java Network API and for any language for that matter, you also have to be familiar with i/o and threads. there are a lot of tutorials out there, i suggest you grab a book. just a thought!