Enable/disable keep-alive functionality, and optionally set the initial
delay before the first keepalive probe is sent on an idle stream.
Set `initialDelay` (in milliseconds) to set the delay between the last
data packet received and the first keepalive probe. Setting 0 for
initialDelay will leave the value unchanged from the default
(or previous) setting.
### stream.remoteAddress
#### stream.remoteAddress
The string representation of the remote IP address. For example,
`'74.125.127.100'` or `'2001:4860:a005::68'`.
This member is only present in server-side connections.
### stream.readyState
#### stream.readyState
Either `'closed'`, `'open'`, `'opening'`, `'readOnly'`, or `'writeOnly'`.
### stream.setEncoding(encoding=null)
#### Event: 'connect'
Sets the encoding (either `'ascii'`, `'utf8'`, or `'base64'`) for data that is
received.
`function () { }`
### stream.setSecure([credentials])
Emitted when a stream connection successfully is established.
See `connect()`.
Enables SSL support for the stream, with the crypto module credentials specifying the private key and certificate of the stream, and optionally the CA certificates for use in peer authentication.
If the credentials hold one ore more CA certificates, then the stream will request for the peer to submit a client certificate as part of the SSL connection handshake. The validity and content of this can be accessed via verifyPeer() and getPeerCertificate().
#### Event: 'secure'
### stream.verifyPeer()
`function () { }`
Returns true or false depending on the validity of the peers's certificate in the context of the defined or default list of trusted CA certificates.
Emitted when a stream connection successfully establishes an SSL handshake with its peer.
### stream.getPeerCertificate()
Returns a JSON structure detailing the peer's certificate, containing a dictionary with keys for the certificate 'subject', 'issuer', 'valid\_from' and 'valid\_to'
#### Event: 'data'
### stream.write(data, encoding='ascii')
`function (data) { }`
Sends data on the stream. The second parameter specifies the encoding in
the case of a string--it defaults to ASCII because encoding to UTF8 is rather
slow.
Emitted when data is received. The argument `data` will be a `Buffer` or
`String`. Encoding of data is set by `stream.setEncoding()`.
(See the section on `Readable Stream` for more information.)
Returns `true` if the entire data was flushed successfully to the kernel
buffer. Returns `false` if all or part of the data was queued in user memory.
`'drain'` will be emitted when the buffer is again free.
#### Event: 'end'
### stream.end([data], [encoding])
`function () { }`
Half-closes the stream. I.E., it sends a FIN packet. It is possible the
server will still send some data. After calling this `readyState` will be
`'readOnly'`.
Emitted when the other end of the stream sends a FIN packet.
If `data` is specified, it is equivalent to calling `stream.write(data, encoding)`
followed by `stream.end()`.
By default (`allowHalfOpen == false`) the stream will destroy its file
descriptor once it has written out its pending write queue. However, by
setting `allowHalfOpen == true` the stream will not automatically `end()`
its side allowing the user to write arbitrary amounts of data, with the
caveat that the user is required to `end()` their side now. In the
`allowHalfOpen == true` case after `'end'` is emitted the `readyState` will
be `'writeOnly'`.
### stream.destroy()
Ensures that no more I/O activity happens on this stream. Only necessary in
case of errors (parse error or so).
#### Event: 'timeout'
### stream.pause()
`function () { }`
Pauses the reading of data. That is, `'data'` events will not be emitted.
Useful to throttle back an upload.
Emitted if the stream times out from inactivity. This is only to notify that
the stream has been idle. The user must manually close the connection.
### stream.resume()
See also: `stream.setTimeout()`
Resumes reading after a call to `pause()`.
### stream.setTimeout(timeout)
#### Event: 'drain'
Sets the stream to timeout after `timeout` milliseconds of inactivity on
the stream. By default `net.Stream` do not have a timeout.
`function () { }`
When an idle timeout is triggered the stream will receive a `'timeout'`
event but the connection will not be severed. The user must manually `end()`
or `destroy()` the stream.
Emitted when the write buffer becomes empty. Can be used to throttle uploads.
If `timeout` is 0, then the existing idle timeout is disabled.
#### Event: 'error'
### stream.setNoDelay(noDelay=true)
`function (exception) { }`
Disables the Nagle algorithm. By default TCP connections use the Nagle
algorithm, they buffer data before sending it off. Setting `noDelay` will
immediately fire off data each time `stream.write()` is called.
Emitted when an error occurs. The `'close'` event will be called directly