at-m42:lecture10
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
at-m42:lecture10 [2009/04/16 14:15] – eechris | at-m42:lecture10 [2011/01/14 12:45] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 255: | Line 255: | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | |||
+ | ===== Even Simpler Groovy Servers ===== | ||
+ | |||
+ | * The '' | ||
+ | * You execute a script (using '' | ||
+ | * You can then connect to that port using a suitable client (e.g. Telnet) | ||
+ | |||
+ | ===== whoAmI again ===== | ||
+ | |||
+ | <cli prompt=">"> | ||
+ | e: | ||
+ | </ | ||
+ | Now in another command window: | ||
+ | <cli prompt=">"> | ||
+ | e: | ||
+ | localhost | ||
+ | ip address: 127.0.0.1 | ||
+ | java.sun.com | ||
+ | ip address: 72.5.124.55 | ||
+ | www.swan.ac.uk | ||
+ | ip address: 137.44.1.7 | ||
+ | </ | ||
+ | |||
+ | ===== Ridiculously simple echo server ===== | ||
+ | |||
+ | When a script is started in listening mode, standard-output is attached to the socket' | ||
+ | <code groovy|Example 7: a really simple echo server (at-m42/ | ||
+ | extern> http:// | ||
+ | </ | ||
+ | |||
+ | Run this as | ||
+ | <cli prompt='>'> | ||
+ | e: | ||
+ | </ | ||
+ | Then run any of the TCP clients developed earlier. | ||
+ | |||
+ | ===== A 75 Line Web Server ====== | ||
+ | |||
+ | To demonstrate the power of Groovy, Jeremy Rayner, one of the core Groovy developers, wrote a simple HTTP server in less than 75 lines of code! | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | It really works: | ||
+ | <cli prompt='>'> | ||
+ | e: | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | <code groovy 1|Example 8: a web server in 74 lines of code> | ||
+ | extern> http:// | ||
+ | </ | ||
===== Firewall Warning ===== | ===== Firewall Warning ===== | ||
You may find that the examples scripts will not run in the PC lab because either Groovy or Java be prevented from openning a port by Windows Firewall. You won't have the necessary privileges to allow. Should work on your own machine. | You may find that the examples scripts will not run in the PC lab because either Groovy or Java be prevented from openning a port by Windows Firewall. You won't have the necessary privileges to allow. Should work on your own machine. | ||
- | |||
---- | ---- |
at-m42/lecture10.1239891329.txt.gz · Last modified: 2011/01/14 12:21 (external edit)