A groovy web server
Based on a suggestion made by Jamie McCrindle, I decided it was time to add some missing Groovy methods related to sockets.
So far, I have added a bunch of IO/streams methods enhancing the JDK core classes, but there were no methods dealing with sockets. But now, this time is over.
I have added two methods:
- Socket.withStreams(Closure) which takes a closure as argument, and has acces to an input stream and an output stream, and
- ServerSocket.accept(Closure) which takes a closure argument which uses a socket as argument
What’s better than a sample code to illustrate that ? Hey, we’re going to implement a simplistic Hello World web server. Here it is…
Read more...