I’ve recently used a site that allows querying WHOIS servers and got annoyed by the requirement of every time typing in the captcha key, so I thought to myself: “Wouldn’t it be groovy to write a Groovy WHOIS client?”. Well, it is :) So without any further ado, I’m presenting that finished script to you.


def domain = args.length > 0
? args[0] : 'google.com'
def server = args.length > 1
? args[1] : 'whois.geektools.com'
new Socket(server, 43).withStreams {input, output ->
output << "${domain}\r\n"
println input.text
}

As you can see, the script uses Groovy extensions to JDK classes, such as Socket (method withStreams(Closure)), InputStream (getText()) and OutputStream(leftShift(Object)). Neat, huh?

Keep on coding!

Psyho

Share/Save/Bookmark

Posted in groovy at September 10th, 2008. by Adam 'Psyho' Pohorecki 2 Comments.

There’s a new contest on GWT Site, and it’s the biggest one yet. There’s 16 prizes to be won, including EXT GWT and GWT Designer licences and copies of three different books on GWT. To enter, you just need to subscribe to the sites email newsletter and/or add a comment to the blog post.

Good luck!

Adam

Share/Save/Bookmark

Posted in gwt at September 9th, 2008. by Adam 'Psyho' Pohorecki 1 Comment.