Represents a socket-like interface to a TCP/SSL connection on either the client or the server side.

Instances of this class are created on the client side by an NetClient when a connection to a server is made, or on the server side by a NetServer when a server accepts a connection.

It provides access to both readStream and writeStream so it can be used with Pump to pump data with flow control.

Instances of this class are not thread-safe.

no subtypes hierarchy

NetSocket(NetSocket delegate)
localAddressshared SocketAddress localAddress

Return the local address for this socket

readStreamshared ReadStream readStream
remoteAddressshared SocketAddress remoteAddress

Return the remote address for this socket

writeHandlerIDshared String writeHandlerID

When a NetSocket is created it automatically registers an event handler with the event bus, the ID of that handler is given by writeHandlerID.

Given this ID, a different event loop can send a buffer to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying connection. This allows you to write data to other connections which are owned by different event loops.

writeStreamshared WriteStream writeStream
Inherited Attributes
Attributes inherited from: Object
hash, string
closeshared void close()

Close the NetSocket

closeHandlershared Promise<Anything> closeHandler()

Returns a promise that will be resolved when the NetSocket is closed

sendFileshared Promise<Anything> sendFile(String fileName)

Tell the kernel to stream a file as specified by fileName] directly, from disk to the outgoing connection, bypassing userspace altogether (where supported by the underlying operating system. This is a very efficient way to serve files.

sslUpgradeshared Promise<Anything> sslUpgrade(void onUpgrade())

Upgrade channel to use SSL/TLS. Be aware that for this to work SSL must be configured.

writeshared NetSocket write(Chunk chunk)

Write a Chunk to the request body.

Inherited Methods
Methods inherited from: Object