The last study in my company was about Scala programming language.
It has some merits for Java programmers to understand it and to use it. Although I can’t explain all about Scala in a limited time, I give a detailed explanation of “Functional programming” and “Traits” which is unfamiliar to Java programmers, and touch on collection operations and Actors the model of concurrency.
In these days I feel comfortable Spring, but it has been suddenly very cold from last week. That’s why I have a sore throat.
By the way, I don’t know why, but I have to implement a server from scratch using sockets recently. So I write about how to implement TCP server in Java, in addition to organizing my ideas.
Handling server sockets in Java
There are three ways to handle server sockets in Java SE 7.
- First, it’s what is called “an ordinary socket API”. We have had it since JDK 1.0, (or this the good old API have existed since 1996) and it’s to use java.net.ServerSocket.
- Second, there is another which handle socket in called “Non-blocking” mode. It’s mainly to use ServerSocketChannel and Selector in java.nio.channels package. It’s added in JDK 1.4.
- And last, there is the last one which handle socket asynchronously. It’s mainly to use AsynchronousServerSocketChannel in java.nio.channels package, too. It’s added in JDK 1.7
Continue reading How to implement TCP server in Java (1)