# Class: NetSocket

## vertx-js/net_socket~ NetSocket

#### new NetSocket()

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

  Source:
    - net_socket.js, line 34

### Methods

#### close()

  Close the NetSocket
  Source:
    - net_socket.js, line 264

#### closeHandler(handler) → {NetSocket}

  Set a handler that will be called when the NetSocket is closed

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function | the handler

  Source:
    - net_socket.js, line 278

  ##### Returns:

  a reference to this, so the API can be used fluently
  Type
    NetSocket

#### drainHandler(handler) → {NetSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function |

  Source:
    - net_socket.js, line 171

  ##### Returns:

  Type
    NetSocket

#### endHandler(endHandler) → {NetSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `endHandler` | function |

  Source:
    - net_socket.js, line 121

  ##### Returns:

  Type
    NetSocket

#### exceptionHandler(handler) → {NetSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function |

  Source:
    - net_socket.js, line 61

  ##### Returns:

  Type
    NetSocket

#### handler(handler) → {NetSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function |

  Source:
    - net_socket.js, line 77

  ##### Returns:

  Type
    NetSocket

#### isSsl() → {boolean}

  Source:
    - net_socket.js, line 308

  ##### Returns:

  - true if this NetSocket is encrypted via SSL/TLS.
  - Type
      boolean

#### localAddress() → {SocketAddress}

  Source:
    - net_socket.js, line 248

  ##### Returns:

  - the local address for this socket
  - Type
      SocketAddress

#### pause() → {NetSocket}

  Source:
    - net_socket.js, line 93

  ##### Returns:

  Type
    NetSocket

#### remoteAddress() → {SocketAddress}

  Source:
    - net_socket.js, line 231

  ##### Returns:

  - the remote address for this socket
  - Type
      SocketAddress

#### resume() → {NetSocket}

  Source:
    - net_socket.js, line 107

  ##### Returns:

  Type
    NetSocket

#### sendFile(filename, resultHandler) → {NetSocket}

  Same as NetSocket#sendFile but also takes a handler that will be called when the send has completed or a failure has occurred

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `filename` | string | file name of the file to send
  `resultHandler` | function | handler

  Source:
    - net_socket.js, line 207

  ##### Returns:

  a reference to this, so the API can be used fluently
  Type
    NetSocket

#### setWriteQueueMaxSize(maxSize) → {NetSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `maxSize` | number |

  Source:
    - net_socket.js, line 157

  ##### Returns:

  Type
    NetSocket

#### upgradeToSsl(handler) → {NetSocket}

  Upgrade channel to use SSL/TLS. Be aware that for this to work SSL must be configured.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function | the handler will be notified when it's upgraded

  Source:
    - net_socket.js, line 293

  ##### Returns:

  a reference to this, so the API can be used fluently
  Type
    NetSocket

#### write(str, enc) → {NetSocket}

  Write a String to the connection, encoded using the encoding `enc`.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `str` | string | the string to write
  `enc` | string | the encoding to use

  Source:
    - net_socket.js, line 137

  ##### Returns:

  a reference to this, so the API can be used fluently
  Type
    NetSocket

#### writeHandlerID() → {string}

  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.

  Source:
    - net_socket.js, line 191

  ##### Returns:

  the write handler ID
  Type
    string

#### writeQueueFull() → {boolean}

  This will return `true` if there are more bytes in the write queue than the value set using NetSocket#setWriteQueueMaxSize
  Source:
    - net_socket.js, line 48

  ##### Returns:

  true if write queue is full
  Type
    boolean