Simple Socket Server and Client Project

Posted by Matt Hagy on April 14, 2020.

Our first project has been created, a Simple Socket Server and Client. In this project, you'll learn the basics of server/client socket programming in Java, including the development of multi-threaded servers and clients. We'll build off this humble starting point in future projects to develop actual database servers and clients. Check it out and let me know what you think at

I'll admit I had previously never done low-level socket programming in Java. Instead, I have always used various frameworks such as netty to handle these low-level details and allow me to focus on the application. In keeping with the spirit of DB From Zero, I chose not to use a framework and instead used the standard Java socket components.

It was surprisingly easy to use components such as ServerSocket and Socket to create the server and client, respectively. While I had expected to have to learn and experiment with a lot of different networking details, I instead found myself just having to write a few lines of code to set everything up. The biggest thing that I had to figure out was how terminate a blocking socket IO operation from another thread, which I learned could be accomplished by calling close on the socket from another thread.

Overall, I'm now actually considering using these low-level socket networking components in my future profession work with Java.