public class SocketGroovyMethods extends DefaultGroovyMethodsSupport
DefaultGroovyMethodsSupport.RangeInfo
Constructor and Description |
---|
SocketGroovyMethods() |
Modifier and Type | Method and Description |
---|---|
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.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.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.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 <T> T |
withObjectStreams(java.net.Socket socket,
Closure<T> closure)
Creates an InputObjectStream and an OutputObjectStream from a Socket, and
passes them to the closure.
|
static <T> T |
withStreams(java.net.Socket socket,
Closure<T> closure)
Passes the Socket's InputStream and OutputStream to the closure.
|
cloneSimilarCollection, cloneSimilarMap, closeQuietly, closeWithWarning, createSimilarArray, createSimilarCollection, createSimilarCollection, createSimilarList, createSimilarMap, createSimilarOrDefaultCollection, createSimilarSet, normaliseIndex, sameType, subListBorders, subListBorders
public static <T> T withStreams(java.net.Socket socket, Closure<T> closure) throws java.io.IOException
socket
- a Socketclosure
- a Closurejava.io.IOException
- if an IOException occurs.public static <T> T withObjectStreams(java.net.Socket socket, Closure<T> closure) throws java.io.IOException
socket
- this Socketclosure
- a Closurejava.io.IOException
- if an IOException occurs.public static java.io.Writer leftShift(java.net.Socket self, java.lang.Object value) throws java.io.IOException
self
- a Socketvalue
- a value to appendjava.io.IOException
- if an IOException occurs.public static java.io.OutputStream leftShift(java.net.Socket self, byte[] value) throws java.io.IOException
self
- a Socketvalue
- a value to appendjava.io.IOException
- if an IOException occurs.public static java.net.Socket accept(java.net.ServerSocket serverSocket, Closure closure) throws java.io.IOException
serverSocket
- a ServerSocketclosure
- a Closurejava.io.IOException
- if an IOException occurs.ServerSocket.accept()
public static java.net.Socket accept(java.net.ServerSocket serverSocket, boolean runInANewThread, Closure closure) throws java.io.IOException
serverSocket
- a ServerSocketrunInANewThread
- This flag should be true, if the closure should be invoked in a new thread, else false.closure
- a Closurejava.io.IOException
- if an IOException occurs.ServerSocket.accept()