|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport org.codehaus.groovy.runtime.SocketGroovyMethods
public class SocketGroovyMethods extends DefaultGroovyMethodsSupport
This class defines new groovy methods for Sockets which enhance JDK classes inside the Groovy environment.
NOTE: While this class contains many 'public' static methods, it is primarily regarded as an internal class (its internal package name suggests this also). We value backwards compatibility of these methods when used within Groovy but value less backwards compatibility at the Java method call level. I.e. future versions of Groovy may remove or move a method call in this file but would normally aim to keep the method available from within Groovy.Method Summary | |
---|---|
static java.net.Socket
|
accept(java.net.ServerSocket serverSocket, Closure closure)
Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread. |
static java.net.Socket
|
accept(java.net.ServerSocket serverSocket, boolean runInANewThread, Closure closure)
Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread or the calling thread, as needed. |
static java.io.Writer
|
leftShift(java.net.Socket self, java.lang.Object value)
Overloads the left shift operator to provide an append mechanism to add things to the output stream of a socket |
static java.io.OutputStream
|
leftShift(java.net.Socket self, byte[] value)
Overloads the left shift operator to provide an append mechanism to add bytes to the output stream of a socket |
static java.lang.Object
|
withObjectStreams(java.net.Socket socket, Closure closure)
Creates an InputObjectStream and an OutputObjectStream from a Socket, and passes them to the closure. |
static java.lang.Object
|
withStreams(java.net.Socket socket, Closure closure)
Passes the Socket's InputStream and OutputStream to the closure. |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Method Detail |
---|
public static java.net.Socket accept(java.net.ServerSocket serverSocket, Closure closure)
serverSocket
- a ServerSocketclosure
- a Closure
public static java.net.Socket accept(java.net.ServerSocket serverSocket, boolean runInANewThread, Closure closure)
serverSocket
- a ServerSocketrunInANewThread
- This flag should be true, if the closure should be invoked in a new thread, else false.closure
- a Closure
public static java.io.Writer leftShift(java.net.Socket self, java.lang.Object value)
self
- a Socketvalue
- a value to append
public static java.io.OutputStream leftShift(java.net.Socket self, byte[] value)
self
- a Socketvalue
- a value to append
public static java.lang.Object withObjectStreams(java.net.Socket socket, Closure closure)
socket
- this Socketclosure
- a Closure
public static java.lang.Object withStreams(java.net.Socket socket, Closure closure)
socket
- a Socketclosure
- a Closure
Groovy Documentation