Do you close the socket?  Usually hasNext is only false on a socket when the socket is closed.

On Mon, May 25, 2015 at 10:48 AM, Eric MacAdie <> wrote:
Hello Groovy users.

I am trying to do some socket programming in Groovy. I am using code found here as a template:

My problem is with the server code.

It reads in the input buffer from a reader using the reader.readLine() method. It turns out it's a BufferedReader.

A problem that I am having is: What if the input is more than one line?

I have been trying for a few hours to get this.

Neither reader.getText(), reader.readLines() nor reader.eachLine() worked.

I tried a few things like this:
def reader = input.newReader()
            def cc = reader.eachLine {
                println "Here is the next element: ${it}"
            println "Done iterating"

            def reader = input.newReader()
            def iter = reader.iterator()
            while ( iter.hasNext() ) {
                println "Here is the next element: ${}"
                println "About to get next, do we have next? "
                println "iter is a ${iter?.getClass()?.getName()}"
            println "Done iterating"

           def holdLine
            while ( ( holdLine = reader.readLine() ) ) {
                println "holdLine: ${holdLine}"
            println "Done"

In each case, it reads each line, but it does not get to the line after the loop.

Maybe there is something obvious that I am missing and I am making a mistake only a noob would make, but why won't the code break out of the loop?

= Eric MacAdie