(abstract) new Sock()
The super class of Socket.
Fires:
Members
id :String
A unique identifier. It will be set up asynchronously from the server in the event 'connect'.
Type:
- String
Methods
connect()
Connect the socket. The socket will be connected automatically by default
so this method is only useful when you use otps.autoConnect: false,
in the constructor.
destroy()
Close the socket.
end()
Send a FIN packet.
getSerializerVersion() → {Number}
Get the version of the underlying serializer.
Returns:
The serializer version.
- Type
- Number
setKeepAlive(enableopt, initialDelayopt)
Enable/disable keep-alive functionality, and optionally set the initial delay before the first
keepalive probe is sent on an idle socket.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
enable |
Boolean |
<optional> |
false | True to enable the TCP keep-alive, false to disable it. |
initialDelay |
Number |
<optional> |
0 | Set the delay in milliseconds between the last data packet received and the first keepalive probe. |
setNoDelay(noDelayopt)
Disables the Nagle algorithm.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
noDelay |
Boolean |
<optional> |
true | True to disable de Nagle algorithm, false to enable it again. |
setTimeout(timeout)
Sets the socket to timeout after 'timeout' milliseconds of inactivity on the socket.
Parameters:
Name | Type | Description |
---|---|---|
timeout |
Number | The timeout in milliseconds or 0 to disable it. |
Events
close
Close event from net.Socket.
end
End event from net.Socket.
error
Error event from net.Socket or Socket.
reconnecting
The socket is trying to reconnect.
socket_connect
Connected underlying net.Socket, all messages in queue will
be sent and new messages will be sent directly.
socket_drain
Emitted when the write buffer of the internal socket becomes empty.
Can be used to throttle uploads.