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.
| Modifier and Type | Field and Description |
|---|---|
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static Socket | Returns: a Socketa ServerSocket serverSocket, final Closure<V> a Closure closure)Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread. |
| public static Socket | Returns: a Socketa ServerSocket serverSocket, final boolean This flag should be true, if the closure should be invoked in a new thread, else false. runInANewThread, final Closure<V> a 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. |
| private static void | |
| public static Writer | |
| public static OutputStream | |
| public static <T> T | Returns: the value returned by the closurethis Socket socket, Closure<T> a Closure closure)Creates an InputObjectStream and an OutputObjectStream from a Socket, and passes them to the closure. |
| public static <T> T | Returns: the value returned by the closurea Socket socket, Closure<T> a Closure closure)Passes the Socket's InputStream and OutputStream to the closure. |
| LOG | back to summary |
|---|---|
| private static final Logger LOG Hides org. | |
| SocketGroovyMethods | back to summary |
|---|---|
| public SocketGroovyMethods() | |
| accept | back to summary |
|---|---|
| public static Socket accept(ServerSocket serverSocket, final Closure<V> closure) throws IOException Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread.
| |
| accept | back to summary |
|---|---|
| public static Socket accept(ServerSocket serverSocket, final boolean runInANewThread, final Closure<V> closure) throws IOException Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread or the calling thread, as needed.
| |
| invokeClosureWithSocket | back to summary |
|---|---|
| private static void invokeClosureWithSocket(Socket socket, Closure<V> closure) | |
| leftShift | back to summary |
|---|---|
| public static Writer leftShift(Socket self, Object value) throws IOException Overloads the left shift operator to provide an append mechanism to add things to the output stream of a socket
| |
| leftShift | back to summary |
|---|---|
| public static OutputStream leftShift(Socket self, byte[] value) throws IOException Overloads the left shift operator to provide an append mechanism to add bytes to the output stream of a socket
| |
| withObjectStreams | back to summary |
|---|---|
| public static <T> T withObjectStreams(Socket socket, Closure<T> closure) throws IOException Creates an InputObjectStream and an OutputObjectStream from a Socket, and passes them to the closure. The streams will be closed after the closure returns, even if an exception is thrown.
| |
| withStreams | back to summary |
|---|---|
| public static <T> T withStreams(Socket socket, Closure<T> closure) throws IOException Passes the Socket's InputStream and OutputStream to the closure. The streams will be closed after the closure returns, even if an exception is thrown.
| |