-
Object
address()
-
Returns the bound address, the address family name and port of the socket as reported by the operating system. Returns an object with three properties, e.g. `{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
Returns:
Object
the remote `family`, `address`, and `port` in an object
-
-
A synchronous version of net.Socket.connect(options).
Note: it does not accept a connectListener as part of the argument
Name |
Type |
Description |
options |
Object
|
number
|
options to use to create the connection. Accepts all the options net.Socket.connect does (as it's just sent to that function). Alternatively can the just the number `port` to connect to. |
host |
string
|
optional
the host to connect to, if options was used as `port`. |
-
disconnect()
-
Disconnects/Destroys the connection and its workers
-
string
read(buffer, blocking)
-
Reads a socket for data. Basically a replacement for on('data');
Name |
Type |
Default |
Description |
buffer |
number
|
16384
|
optional
how many bytes to read from the buffer |
blocking |
boolean
|
false
|
optional
True if you want to block the read until data is available, false/undefined otherwise (normal behavior) |
Returns:
string
string read from the socket, or undefined if no data to read
-
write(data, encoding)
-
Writes data to the socket
Name |
Type |
Description |
data |
string
|
data to write to the socket |
encoding |
string
|
optional
encoding of the data being written, defaults to 'utf-8' |