implicit final class SocketExtensions[T <: Socket] extends AnyVal
net.Socket Extensions
- Alphabetic
- By Inheritance
- SocketExtensions
- AnyVal
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- Any
- final def ##: Int
- Definition Classes
- Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def connectFuture(port: Int, host: String): Future[Unit]
Opens the connection for a given socket.
Opens the connection for a given socket.
- port
the port number
- host
the host name or IP
- returns
a promise of an outcome
- Annotations
- @inline()
- def connectFuture(port: Int): Future[Unit]
Opens the connection for a given socket.
Opens the connection for a given socket.
- port
the port number
- returns
a promise of an outcome
- Annotations
- @inline()
- def connectFuture(path: String): Future[Unit]
Opens the connection for a given socket.
Opens the connection for a given socket.
- path
the connection path
- returns
a promise of an outcome
- Annotations
- @inline()
- def getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def onClose(callback: (Boolean) => Any): T
Emitted once the socket is fully closed.
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.
- callback
- had_error <Boolean> true if the socket had a transmission error.
- Annotations
- @inline()
socket.on("close", function(had_error) { ... })
Example: - def onConnect(callback: () => Any): T
Emitted when a socket connection is successfully established.
Emitted when a socket connection is successfully established. See connect().
- callback
the callback
- Annotations
- @inline()
socket.on("connect", function() { ... })
Example: - def onData(callback: (|[Buffer, String]) => Any): T
Emitted when data is received.
Emitted when data is received. The argument data will be a Buffer or String. Encoding of data is set by socket.setEncoding(). (See the Readable Stream section for more information.)
Note that the data will be lost if there is no listener when a Socket emits a 'data' event.
- callback
- <Buffer>
- Annotations
- @inline()
socket.on("data", function(buffer) { ... })
Example: - def onDrain(callback: () => Any): T
Emitted when the write buffer becomes empty.
Emitted when the write buffer becomes empty. Can be used to throttle uploads.
See also: the return values of socket.write()
- callback
the callback
- Annotations
- @inline()
socket.on("drain", function() { ... })
Example: - def onEnd(callback: () => Any): T
Emitted when the other end of the socket sends a FIN packet.
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.
- callback
the callback
- Annotations
- @inline()
socket.on("end", function() { ... })
Example: - def onError(callback: (Error) => Any): T
- Annotations
- @inline()
- def onLookup(callback: (Error, String, String, String) => Any): T
Emitted after resolving the hostname but before connecting.
Emitted after resolving the hostname but before connecting. Not applicable to UNIX sockets.
- callback
the callback, with the following arguments:
- err <Error> | <Null> The error object. See dns.lookup().
- address <String> The IP address.
- family <String> | <Null> The address type. See dns.lookup().
- host <String> The hostname.
- Annotations
- @inline()
socket.on("lookup", function(err, address, family, host) { ... })
Example: - def onReady(callback: () => Any): T
- Annotations
- @inline()
- def onTimeout(callback: Function): T
Emitted if the socket times out from inactivity.
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()
- callback
the callback
- Annotations
- @inline()
socket.on("timeout", function() { ... })
Example: - def toString(): String
- Definition Classes
- Any