Package: java.net

## [Java] Class Socket

- java.net.Socket

-     public class Socket
      extends Object

  GDK enhancements for Socket.

  displayName:
    Socket
  receiverFqcn:
    java.net.Socket

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Writer` | `leftShift(Object value)` Overloads the left shift operator to provide an append mechanism to add things to the output stream of a socket
    `` | `public OutputStream` | `leftShift(byte[] value)` Overloads the left shift operator to provide an append mechanism to add bytes to the output stream of a socket
    `<T>` | `public T` | `withObjectStreams(Closure<T> closure)` Creates an InputObjectStream and an OutputObjectStream from a Socket, and passes them to the closure.
    `<T>` | `public T` | `withStreams(Closure<T> closure)` Passes the Socket's InputStream and OutputStream to the closure.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `addShutdownHook, any, any, asBoolean, asType, clamp, clamp, collect, collect, collect, dump, each, eachMatch, eachMatch, eachWithIndex, every, every, find, find, findAll, findAll, findIndexOf, findIndexOf, findIndexValues, findIndexValues, findLastIndexOf, findLastIndexOf, findResult, findResult, findResult, findResult, getAt, getMetaClass, getMetaPropertyValues, getProperties, grep, grep, hasProperty, identity, inject, inject, inspect, invokeMethod, is, isCase, isNotCase, iterator, metaClass, print, print, printf, printf, println, println, println, putAt, respondsTo, respondsTo, setMetaClass, sleep, sleep, split, sprintf, sprintf, stream, takeIf, tap, toString, use, use, use, with, with, withCloseable, withCloseable, withMethodClosure, withStream, withStream, withTraits`

- - ### Method Detail

    - #### public Writer leftShift(Object value)

      Overloads the left shift operator to provide an append mechanism to add things to the output stream of a socket

      throws:
        IOException if an IOException occurs.
      Parameters:
        `value` - a value to append
      Returns:
        a Writer
      Since:
        1.0

    - #### public OutputStream leftShift(byte[] value)

      Overloads the left shift operator to provide an append mechanism to add bytes to the output stream of a socket

      throws:
        IOException if an IOException occurs.
      Parameters:
        `value` - a value to append
      Returns:
        an OutputStream
      Since:
        1.0

    - #### <T> public T withObjectStreams(Closure<T> closure)

      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.

      throws:
        IOException if an IOException occurs.
      Parameters:
        `closure` - a Closure
      Returns:
        the value returned by the closure
      Since:
        1.5.0

    - #### <T> public T withStreams(Closure<T> closure)

      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.

      throws:
        IOException if an IOException occurs.
      Parameters:
        `closure` - a Closure
      Returns:
        the value returned by the closure
      Since:
        1.5.2