A net.Socket subclass that represents the writable portion of a tty. In normal circumstances, process.stdout will be the only tty.WriteStream instance ever created (and only when isatty(1) is true).

Variables

read onlycolumns:Int

The number of columns the TTY currently has. This property gets updated on "resize" events.

read onlyrows:Int

The number of rows the TTY currently has. This property gets updated on "resize" events.

Inherited Variables

Defined by Socket

bufferSize:Int

Socket has the property that socket.write always works. This is to help users get up and running quickly. The computer cannot always keep up with the amount of data that is written to a socket - the network connection simply might be too slow. Node will internally queue up the data written to a socket and send it out over the wire when it is possible. (Internally it is polling on the socket's file descriptor for being writable).

The consequence of this internal buffering is that memory may grow. This property shows the number of characters currently buffered to be written. (Number of characters is approximately equal to the number of bytes to be written, but the buffer may contain strings, and the strings are lazily encoded, so the exact number of bytes is not known.)

Users who experience large or growing bufferSize should attempt to "throttle" the data flows in their program with pause and resume.

read onlybytesRead:Int

The amount of received bytes.

read onlybytesWritten:Int

The amount of bytes sent.

read onlyencrypted:Bool

Always true for TLSSocket instances.

May be used to distinguish TLS sockets from regular ones.

read onlylocalAddress:String

The string representation of the local IP address the remote client is connecting on. For example, if you are listening on '0.0.0.0' and the client connects on '192.168.1.1', the value would be '192.168.1.1'.

read onlylocalPort:Int

The numeric representation of the local port. For example, 80 or 21.

read onlyremoteAddress:String

The string representation of the remote IP address. For example, '74.125.127.100' or '2001:4860:a005::68'.

read onlyremoteFamily:SocketAdressFamily

The string representation of the remote IP family. 'IPv4' or 'IPv6'.

read onlyremotePort:Int

The numeric representation of the remote port. For example, 80 or 21.

Defined by Duplex

read onlywritable:Bool

Is true if it is safe to call writable.write().

See also:

read onlywritableEnded:Bool

Is true after writable.end() has been called. This property does not indicate whether the data has been flushed, for this use writable.writableFinished instead.

See also:

read onlywritableFinished:Bool

Is set to true immediately before the 'finish' event is emitted.

See also:

read onlywritableLength:Int

This property contains the number of bytes (or objects) in the queue ready to be written. The value provides introspection data regarding the status of the highWaterMark.

See also:

read onlywritableObjectMode:Bool

Getter for the property objectMode of a given Writable stream.

See also:

read onlywritablehighWaterMark:Int

Return the value of highWaterMark passed when constructing this Writable.

See also:

Defined by Readable

read onlydestroyed:Bool

Is true after readable.destroy() has been called.

See also:

read onlyisTTY:Bool

Terminal read streams (i.e. process.stdin) have this property set to true. It is false for any other read streams.

See also:

read onlyreadable:Bool

Is true if it is safe to call readable.read().

See also:

read onlyreadableEncoding:Null<String>

Getter for the property encoding of a given Readable stream. The encoding property can be set using the readable.setEncoding() method.

See also:

read onlyreadableHighWaterMark:Int

Returns the value of highWaterMark passed when constructing this Readable.

See also:

read onlyreadableLength:Int

This property contains the number of bytes (or objects) in the queue ready to be read. The value provides introspection data regarding the status of the highWaterMark.

See also:

read onlyreadableObjectMode:Bool

Getter for the property objectMode of a given Readable stream.

See also:

Inherited Methods

Defined by Socket

address():SocketAdress

Returns the bound address, the address family name and port of the socket as reported by the operating system.

connect(options:EitherType<SocketConnectOptionsTcp, SocketConnectOptionsUnix>, ?connectListener:() ‑> Void):Socket

connect(path:String, ?connectListener:() ‑> Void):Socket

connect(port:Int, ?connectListener:() ‑> Void):Socket

connect(port:Int, host:String, ?connectListener:() ‑> Void):Socket

Opens the connection for a given socket.

If port and host are given, then the socket will be opened as a TCP socket, if host is omitted, localhost will be assumed. If a path is given, the socket will be opened as a unix socket to that path.

Normally this method is not needed, as Net.createConnection opens the socket. Use this only if you are implementing a custom Socket.

This function is asynchronous. When the 'connect' event is emitted the socket is established. If there is a problem connecting, the 'connect' event will not be emitted, the 'error' event will be emitted with the exception

The connectListener parameter will be added as an listener for the 'connect' event.

destroy(?exception:Error):Void

A boolean value that indicates if the connection is destroyed or not. Once a connection is destroyed no further data can be transferred using it.

define in Stream/Readable.hx

ref():Socket

Opposite of unref, calling ref on a previously unrefd socket will not let the program exit if it's the only socket left (the default behavior). If the socket is refd calling ref again will have no effect.

setKeepAlive(enable:Bool, ?initialDelay:Int):Void

setKeepAlive(?initialDelay:Int):Void

Enable/disable keep-alive functionality, and optionally set the initial delay before the first keepalive probe is sent on an idle socket.

enable defaults to false.

Set initialDelay (in milliseconds) to set the delay between the last data packet received and the first keepalive probe.

Setting 0 for initialDelay will leave the value unchanged from the default (or previous) setting. Defaults to 0.

setNoDelay(?noDelay:Bool):Void

Disables the Nagle algorithm. By default TCP connections use the Nagle algorithm, they buffer data before sending it off. Setting true for noDelay will immediately fire off data each time write is called. noDelay defaults to true.

setTimeout(timeout:Int, ?callback:() ‑> Void):Void

Sets the socket to timeout after timeout milliseconds of inactivity on the socket. By default Socket do not have a timeout.

When an idle timeout is triggered the socket will receive a 'timeout' event but the connection will not be severed. The user must manually end or destroy the socket.

If timeout is 0, then the existing idle timeout is disabled.

The optional callback parameter will be added as a one time listener for the 'timeout' event.

unref():Socket

Calling unref on a socket will allow the program to exit if this is the only active socket in the event system. If the socket is already unrefd calling unref again will have no effect.

Defined by Duplex

cork():Void

The writable.cork() method forces all written data to be buffered in memory. The buffered data will be flushed when either the stream.uncork() or stream.end() methods are called.

See also:

end(chunk:Dynamic, ?encoding:String, ?callback:EitherType<() ‑> Void, Null<Error> ‑> Void>):Void

end(?callback:EitherType<() ‑> Void, Null<Error> ‑> Void>):Void

Calling the writable.end() method signals that no more data will be written to the Writable. The optional chunk and encoding arguments allow one final additional chunk of data to be written immediately before closing the stream. If provided, the optional callback function is attached as a listener for the 'finish' event.

See also:

setDefaultEncoding(encoding:String):TSelf

The writable.setDefaultEncoding() method sets the default encoding for a Writable stream.

See also:

uncork():Void

The writable.uncork() method flushes all data buffered since stream.cork() was called.

See also:

write(chunk:Dynamic, ?encoding:String, ?callback:EitherType<() ‑> Void, Null<Error> ‑> Void>):Bool

The writable.write() method writes some data to the stream, and calls the supplied callback once the data has been fully handled. If an error occurs, the callback may or may not be called with the error as its first argument. To reliably detect write errors, add a listener for the 'error' event.

See also:

Defined by Readable

isPaused():Bool

The readable.isPaused() method returns the current operating state of the Readable. This is used primarily by the mechanism that underlies the readable.pipe() method. In most typical cases, there will be no reason to use this method directly.

See also:

pause():TSelf

The readable.pause() method will cause a stream in flowing mode to stop emitting 'data' events, switching out of flowing mode. Any data that becomes available will remain in the internal buffer.

See also:

pipe<T>(destination:T, ?options:{end:Null<Bool>}):T

The readable.pipe() method attaches a Writable stream to the readable, causing it to switch automatically into flowing mode and push all of its data to the attached Writable. The flow of data will be automatically managed so that the destination Writable stream is not overwhelmed by a faster Readable stream.

See also:

read(?size:Int):Null<Dynamic>

The readable.read() method pulls some data out of the internal buffer and returns it. If no data available to be read, null is returned. By default, the data will be returned as a Buffer object unless an encoding has been specified using the readable.setEncoding() method or the stream is operating in object mode.

See also:

resume():TSelf

The readable.resume() method causes an explicitly paused Readable stream to resume emitting 'data' events, switching the stream into flowing mode.

See also:

setEncoding(encoding:String):TSelf

The readable.setEncoding() method sets the character encoding for data read from the Readable stream.

See also:

unpipe(?destination:IWritable):TSelf

The readable.unpipe() method detaches a Writable stream previously attached using the stream.pipe() method.

See also:

unshift(chunk:Null<Dynamic>, ?encoding:String):Void

Passing chunk as null signals the end of the stream (EOF), after which no more data can be written.

See also:

wrap(stream:Dynamic):IReadable

Prior to Node.js 0.10, streams did not implement the entire stream module API as it is currently defined. (See Compatibility for more information.)

See also:

Defined by EventEmitter

addListener<T>(eventName:Event<T>, listener:T):TSelf

emit<T>(eventName:Event<T>, args:Rest<Dynamic>):Bool

Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

See also:

eventNames():Array<EitherType<String, Symbol>>

Returns an array listing the events for which the emitter has registered listeners. The values in the array will be strings or Symbols.

See also:

getMaxListeners():Int

Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to EventEmitter.defaultMaxListeners.

See also:

listenerCount<T>(eventName:Event<T>):Int

Returns the number of listeners listening to the event named eventName.

See also:

listeners<T>(eventName:Event<T>):Array<T>

Returns a copy of the array of listeners for the event named eventName.

See also:

off<T>(eventName:Event<T>, listener:T):TSelf

on<T>(eventName:Event<T>, listener:T):TSelf

Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

See also:

once<T>(eventName:Event<T>, listener:T):TSelf

Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

See also:

prependListener<T>(eventName:Event<T>, listener:T):TSelf

Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

See also:

prependOnceListener<T>(eventName:Event<T>, listener:T):TSelf

Adds a one-time listener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.

See also:

rawListeners<T>(eventName:Event<T>):Array<T>

Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).

See also:

removeAllListeners<T>(?eventName:Event<T>):TSelf

Removes all listeners, or those of the specified eventName.

See also:

removeListener<T>(eventName:Event<T>, listener:T):TSelf

Removes the specified listener from the listener array for the event named eventName.

See also:

setMaxListeners(n:Int):Void

By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. Obviously, not all events should be limited to just 10 listeners. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

See also: