# Class: NetServer

## vertx-js/net_server~ NetServer

#### new NetServer()

Represents a TCP server

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

### 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 165

##### 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 142

#### 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 77

##### 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 61

##### Returns:

the connect stream

Type
  ReadStream

#### isMetricsEnabled() → {boolean}

Whether the metrics are enabled for this measured object

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

##### 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 95

##### Returns:

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

Type
  NetServer