org.vertx.java.core.net.impl

## Class DefaultNetSocket

- java.lang.Object
- - org.vertx.java.core.net.impl.ConnectionBase
  - - org.vertx.java.core.net.NetSocket
    - - org.vertx.java.core.net.impl.DefaultNetSocket

All Implemented Interfaces:
  ReadStream, WriteStream

    public class DefaultNetSocket
    extends NetSocket

### Field Summary

### Fields inherited from class org.vertx.java.core.net.NetSocket

`writeHandlerID`

### Fields inherited from class org.vertx.java.core.net.impl.ConnectionBase

`channel, closedHandler, context, exceptionHandler, vertx`

### Constructor Summary

Constructors
Constructor and Description
`DefaultNetSocket(VertxInternal vertx, org.jboss.netty.channel.Channel channel, Context context)`

### Method Summary

Methods
`void` `dataHandler(Handler<Buffer> dataHandler)` Set a data handler.
`void` `drainHandler(Handler<java.lang.Void> drainHandler)` Set a drain handler on the stream.
`void` `endHandler(Handler<java.lang.Void> endHandler)` Set an end handler.
`protected Context` `getContext()`
`protected void` `handleClosed()`
`void` `sendFile(java.lang.String filename)` Tell the kernel 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.
`NetSocket` `write(Buffer data)` Write a `Buffer` to the request body.
`NetSocket` `write(Buffer data, Handler<java.lang.Void> doneHandler)` Write a `Buffer` to the connection.
`NetSocket` `write(java.lang.String str)` Write a `String` to the connection, encoded in UTF-8.
`NetSocket` `write(java.lang.String str, Handler<java.lang.Void> doneHandler)` Write a `String` to the connection, encoded in UTF-8.
`NetSocket` `write(java.lang.String str, java.lang.String enc)` Write a `String` to the connection, encoded using the encoding `enc`.
`NetSocket` `write(java.lang.String str, java.lang.String enc, Handler<java.lang.Void> doneHandler)` Write a `String` to the connection, encoded with encoding `enc`.
`void` `writeBuffer(Buffer data)` Write some data to the stream.

### Methods inherited from class org.vertx.java.core.net.impl.ConnectionBase

`addFuture, close, closedHandler, exceptionHandler, handleException, handleHandlerException, isSSL, pause, resume, sendFile, setContext, setWriteQueueMaxSize, writeQueueFull`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.vertx.java.core.streams.ReadStream

`exceptionHandler, pause, resume`

### Methods inherited from interface org.vertx.java.core.streams.WriteStream

`exceptionHandler, setWriteQueueMaxSize, writeQueueFull`

### Constructor Detail

#### DefaultNetSocket

    public DefaultNetSocket(VertxInternal vertx,
                    org.jboss.netty.channel.Channel channel,
                    Context context)

### Method Detail

#### writeBuffer

    public void writeBuffer(Buffer data)

Description copied from class: `NetSocket`
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 `WriteStream.writeQueueFull()` method before writing. This is done automatically if using a `Pump`.

Specified by:
  `writeBuffer` in interface `WriteStream`
Specified by:
  `writeBuffer` in class `NetSocket`

#### write

    public NetSocket write(Buffer data)

Description copied from class: `NetSocket`
Write a `Buffer` to the request body.

Specified by:
  `write` in class `NetSocket`
Returns:
  A reference to this, so multiple method calls can be chained.

#### write

    public NetSocket write(java.lang.String str)

Description copied from class: `NetSocket`
Write a `String` to the connection, encoded in UTF-8.

Specified by:
  `write` in class `NetSocket`
Returns:
  A reference to this, so multiple method calls can be chained.

#### write

    public NetSocket write(java.lang.String str,
                  java.lang.String enc)

Description copied from class: `NetSocket`
Write a `String` to the connection, encoded using the encoding `enc`.

Specified by:
  `write` in class `NetSocket`
Returns:
  A reference to this, so multiple method calls can be chained.

#### write

    public NetSocket write(Buffer data,
                  Handler<java.lang.Void> doneHandler)

Description copied from class: `NetSocket`
Write a `Buffer` to the connection. The `doneHandler` is called after the buffer is actually written to the wire.

Specified by:
  `write` in class `NetSocket`
Returns:
  A reference to this, so multiple method calls can be chained.

#### write

    public NetSocket write(java.lang.String str,
                  Handler<java.lang.Void> doneHandler)

Description copied from class: `NetSocket`
Write a `String` to the connection, encoded in UTF-8. The `doneHandler` is called after the buffer is actually written to the wire.

Specified by:
  `write` in class `NetSocket`
Returns:
  A reference to this, so multiple method calls can be chained.

#### write

    public NetSocket write(java.lang.String str,
                  java.lang.String enc,
                  Handler<java.lang.Void> doneHandler)

Description copied from class: `NetSocket`
Write a `String` to the connection, encoded with encoding `enc`. The `doneHandler` is called after the buffer is actually written to the wire.

Specified by:
  `write` in class `NetSocket`
Returns:
  A reference to this, so multiple method calls can be chained.

#### dataHandler

    public void dataHandler(Handler<Buffer> dataHandler)

Description copied from class: `NetSocket`
Set a data handler. As data is read, the handler will be called with the data.

Specified by:
  `dataHandler` in interface `ReadStream`
Specified by:
  `dataHandler` in class `NetSocket`

#### endHandler

    public void endHandler(Handler<java.lang.Void> endHandler)

Description copied from class: `NetSocket`
Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.

Specified by:
  `endHandler` in interface `ReadStream`
Specified by:
  `endHandler` in class `NetSocket`

#### drainHandler

    public void drainHandler(Handler<java.lang.Void> drainHandler)

Description copied from class: `NetSocket`
Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue has been reduced to maxSize / 2. See `Pump` for an example of this being used.

Specified by:
  `drainHandler` in interface `WriteStream`
Specified by:
  `drainHandler` in class `NetSocket`

#### sendFile

    public void sendFile(java.lang.String filename)

Description copied from class: `NetSocket`
Tell the kernel 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.

Specified by:
  `sendFile` in class `NetSocket`

#### getContext

    protected Context getContext()

Overrides:
  `getContext` in class `ConnectionBase`

#### handleClosed

    protected void handleClosed()

Overrides:
  `handleClosed` in class `ConnectionBase`