Enumeration of events for Socket objects.

Variables

@:value(cast "close")@:enum@:implinlineread onlyClose:SocketEvent<Bool ‑> Void> = "close"

Emitted once the socket is fully closed. The argument had_error is a boolean which says if the socket was closed due to a transmission error.

Listener arguments:

had_error - true if the socket had a transmission error

@:value(cast "connect")@:enum@:implinlineread onlyConnect:SocketEvent<() ‑> Void> = "connect"

Emitted when a socket connection is successfully established. See Socket.connect.

@:value(cast "data")@:enum@:implinlineread onlyData:SocketEvent<EitherType<Buffer, String> ‑> Void> = "data"

Emitted when data is received. The argument data will be a Buffer or String. Encoding of data is set by Socket.setEncoding.

Note that the data will be lost if there is no listener when a Socket emits a 'data' event.

@:value(cast "drain")@:enum@:implinlineread onlyDrain:SocketEvent<() ‑> Void> = "drain"

Emitted when the write buffer becomes empty. Can be used to throttle uploads. See also: the return values of Socket.write

@:value(cast "end")@:enum@:implinlineread onlyEnd:SocketEvent<() ‑> Void> = "end"

Emitted when the other end of the socket sends a FIN packet.

By default (allowHalfOpen == false) the socket will destroy its file descriptor once it has written out its pending write queue. However, by setting allowHalfOpen == true the socket 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.

@:value(cast "error")@:enum@:implinlineread onlyError:SocketEvent<Error ‑> Void> = "error"

Emitted when an error occurs. The 'close' event will be called directly following this event.

@:value(cast "lookup")@:enum@:implinlineread onlyLookup:SocketEvent<(Null<Error>, String, DnsAddressFamily) ‑> Void> = "lookup"

Emitted after resolving the hostname but before connecting. Not applicable to UNIX sockets.

@:value(cast "timeout")@:enum@:implinlineread onlyTimeout:SocketEvent<() ‑> Void> = "timeout"

Emitted if the socket times out from inactivity. This is only to notify that the socket has been idle The user must manually close the connection. See also: Socket.setTimeout