Represents a socket-like interface to a TCP connection on either the client or the server side.

Instances of this class are created on the client side by an NetClient when a connection to a server is made, or on the server side by a NetServer when a server accepts a connection.

It implements both and so it can be used with Pump to pump data with flow control.

- `Anything`
  - `Object`
    - `Basic` ...and other supertypes
      - `NetSocket` ...and other supertypes

- `NetSocket`
  - `Basic`
    - `Identifiable`
    - `Object`
      - `Anything`
  - `ReadStream`
    - `StreamBase`
  - `WriteStream`
    - `StreamBase`

no subtypes hierarchy

Initializer
`NetSocket(NetSocket unknown)`

Inherited Attributes
Attributes inherited from: `Object` `hash`, `string`

Methods
`close` | `shared default void close()` Close the NetSocket
`closeHandler` | `shared default NetSocket closeHandler(Anything()? handler)` Set a handler that will be called when the NetSocket is closed Parameters: `handler` the handler
`drainHandler` | `shared actual default NetSocket drainHandler(Anything()? handler)` Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. See Pump for an example of this being used. The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced to `maxSize / 2`. Refines `WriteStream.drainHandler`
`end` | `shared actual default void end()` Calls close Refines `WriteStream.end`
`end` | `shared actual default void end(Buffer t)` Same as end but writes some data to the stream before ending. Refines `WriteStream.end`
`endHandler` | `shared actual default NetSocket endHandler(Anything()? endHandler)` Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called. Refines `ReadStream.endHandler`
`exceptionHandler` | `shared actual default NetSocket exceptionHandler(Anything(Throwable)? handler)` Set an exception handler. Refines `StreamBase.exceptionHandler`
`handler` | `shared actual default NetSocket handler(Anything(Buffer)? handler)` Set a data handler. As data is read, the handler will be called with the data. Refines `ReadStream.handler`
`isSsl` | `shared default Boolean isSsl()`
`localAddress` | `shared default SocketAddress localAddress()`
`pause` | `shared actual default NetSocket pause()` Pause the `ReadSupport`. While it's paused, no data will be sent to the `dataHandler` Refines `ReadStream.pause`
`remoteAddress` | `shared default SocketAddress remoteAddress()`
`resume` | `shared actual default NetSocket resume()` Resume reading. If the `ReadSupport` has been paused, reading will recommence on it. Refines `ReadStream.resume`
`sendFile` | `shared default NetSocket sendFile(String filename)` Tell the operating system to stream a file as specified by `filename` directly from disk to the outgoing connection, bypassing userspace altogether (where supported by the underlying operating system. This is a very efficient way to stream files. Parameters: `filename` file name of the file to send
`sendFile` | `shared default NetSocket sendFile(String filename, Anything(Throwable?) resultHandler)` Same as sendFile but also takes a handler that will be called when the send has completed or a failure has occurred Parameters: `filename` file name of the file to send `resultHandler` handler
`sendFile` | `shared default NetSocket sendFile(String filename, Integer offset)` Tell the operating system to stream a file as specified by `filename` directly from disk to the outgoing connection, bypassing userspace altogether (where supported by the underlying operating system. This is a very efficient way to stream files. Parameters: `filename` file name of the file to send `offset` offset
`sendFile` | `shared default NetSocket sendFile(String filename, Integer offset, Anything(Throwable?) resultHandler)` Same as sendFile but also takes a handler that will be called when the send has completed or a failure has occurred Parameters: `filename` file name of the file to send `offset` offset `resultHandler` handler
`sendFile` | `shared default NetSocket sendFile(String filename, Integer offset, Integer length)` Tell the operating system to stream a file as specified by `filename` directly from disk to the outgoing connection, bypassing userspace altogether (where supported by the underlying operating system. This is a very efficient way to stream files. Parameters: `filename` file name of the file to send `offset` offset `length` length
`sendFile` | `shared default NetSocket sendFile(String filename, Integer offset, Integer length, Anything(Throwable?) resultHandler)` Same as sendFile but also takes a handler that will be called when the send has completed or a failure has occurred Parameters: `filename` file name of the file to send `offset` offset `length` length `resultHandler` handler
`setWriteQueueMaxSize` | `shared actual default NetSocket setWriteQueueMaxSize(Integer maxSize)` Set the maximum size of the write queue to `maxSize`. You will still be able to write to the stream even if there is more than `maxSize` items in the write queue. This is used as an indicator by classes such as `Pump` to provide flow control. The value is defined by the implementation of the stream, e.g in bytes for a NetSocket, the number of Message for a MessageProducer, etc… Refines `WriteStream.setWriteQueueMaxSize`
`upgradeToSsl` | `shared default NetSocket upgradeToSsl(Anything() handler)` Upgrade channel to use SSL/TLS. Be aware that for this to work SSL must be configured. Parameters: `handler` the handler will be notified when it's upgraded
`write` | `shared actual default NetSocket write(Buffer data)` Write some data to the stream. The data is put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the writeQueueFull method before writing. This is done automatically if using a Pump. Refines `WriteStream.write`
`write` | `shared default NetSocket write(String str)` Write a `String` to the connection, encoded in UTF-8. Parameters: `str` the string to write
`write` | `shared default NetSocket write(String str, String enc)` Write a `String` to the connection, encoded using the encoding `enc`. Parameters: `str` the string to write `enc` the encoding to use
`writeHandlerID` | `shared default String writeHandlerID()` When a `NetSocket` is created it automatically registers an event handler with the event bus, the ID of that handler is given by `writeHandlerID`. Given this ID, a different event loop can send a buffer to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying connection. This allows you to write data to other connections which are owned by different event loops.
`writeQueueFull` | `shared actual default Boolean writeQueueFull()` This will return `true` if there are more bytes in the write queue than the value set using setWriteQueueMaxSize Refines `WriteStream.writeQueueFull`

Inherited Methods
Methods inherited from: `Object` `equals`
Methods inherited from: `ReadStream<T>` `endHandler()`, `exceptionHandler()`, `handler()`, `pause()`, `resume()`
Methods inherited from: `StreamBase` `exceptionHandler()`
Methods inherited from: `WriteStream<T>` `drainHandler()`, `end()`, `exceptionHandler()`, `setWriteQueueMaxSize()`, `write()`, `writeQueueFull()`