Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Change new ServerSocket() to new ServerSocket(0), which actually binds and opens the port for listening (matching the comment). The example did not work me until I did this.

...

  1. Create a server object
    Code Block
    java
    java
    import groovy.net.xmlrpc.*
    import java.net.ServerSocket
    
    def server = new XMLRPCServer()
    
  2. Add some methods
    Code Block
    java
    java
    server.echo = {return it}  // the closure is now named "echo" and is remotely callable
    
  3. Start the server
    Code Block
    java
    java
    def serverSocket = new ServerSocket() 0 )    // Open a server socket on a free port
    server.startServer(serverSocket)           // Start the XML-RPC server listening on the server socket
    
  4. You're done!

...