# Class: NetServer

## vertx-js/net_server~ NetServer

#### new NetServer()

Represents a TCP server

Source:
  - vertx-js/net_server.js, line 33

### Methods

#### actualPort() → {number}

The actual port the server is listening on. This is useful if you bound the server specifying 0 as port number signifying an ephemeral port

Source:
  - vertx-js/net_server.js, line 196

##### Returns:

the actual port the server is listening on.

Type
  number

#### close(completionHandler)

Like NetServer#close but supplying a handler that will be notified when close is complete.

##### Parameters:

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

Source:
  - vertx-js/net_server.js, line 173

#### connectHandler(handler) → {NetServer}

Supply a connect handler for this server. The server can only have at most one connect handler at any one time. As the server accepts TCP or SSL connections it creates an instance of NetSocket and passes it to the connect handler.

##### Parameters:

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

Source:
  - vertx-js/net_server.js, line 78

##### Returns:

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

Type
  NetServer

#### connectStream() → {ReadStream}

Return the connect stream for this server. The server can only have at most one handler at any one time. As the server accepts TCP or SSL connections it creates an instance of NetSocket and passes it to the connect stream .

Source:
  - vertx-js/net_server.js, line 62

##### Returns:

the connect stream

Type
  ReadStream

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

Set an exception handler called for socket errors happening before the connection is passed to the NetServer#connectHandler, e.g during the TLS handshake.

##### Parameters:

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

Source:
  - vertx-js/net_server.js, line 157

##### Returns:

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

Type
  NetServer

#### isMetricsEnabled() → {boolean}

Whether the metrics are enabled for this measured object

Source:
  - vertx-js/net_server.js, line 46

##### Returns:

true if the metrics are enabled

Type
  boolean

#### listen(port, host, listenHandler) → {NetServer}

Like NetServer#listen but providing a handler that will be notified when the server is listening, or fails.

##### Parameters:

Name | Type | Description
--- | --- | ---
`port` | number | the port to listen on
`host` | string | the host to listen on
`listenHandler` | function | handler that will be notified when listening or failed

Source:
  - vertx-js/net_server.js, line 96

##### Returns:

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

Type
  NetServer