Class

Socket

Socket()

Constructor

# new Socket()

View Source doc/classes.js, line 460

Methods

# Close(doFlushopt)

close the socket.
Parameters:
Name Type Attributes Default Description
doFlush boolean <optional>
false flush before close.

View Source doc/classes.js, line 471

# DataReady() → {number}

Get number of bytes waiting to be read.

View Source doc/classes.js, line 535

number of bytes waiting to be read.
number

# Established() → {boolean}

Check if the socket connection is established.

View Source doc/classes.js, line 541

true if the connection is established.
boolean

# Flush(flushWaitopt)

Send pending TCP data.
Parameters:
Name Type Attributes Default Description
flushWait boolean <optional>
false wait until data is flushed.

View Source doc/classes.js, line 519

# Flush()

flush the socket output to the network.

View Source doc/classes.js, line 465

# FlushNext()

Causes next transmission to have a flush (PUSH bit set).

View Source doc/classes.js, line 529

# GetLocalPort() → {number}

Get the local port number.

View Source doc/classes.js, line 553

the local port number.
number

# GetRemoteHost() → {IpAddress}

Get the remote host ip

View Source doc/classes.js, line 547

IP of the remote host.
IpAddress

# GetRemotePort() → {number}

Get the remote port number.

View Source doc/classes.js, line 559

the remote port number.
number

# Mode(mode)

Set binary or ascii mode for UDP/TCP sockets.
Parameters:
Name Type Description
mode number one of SOCKET.MODE.

View Source doc/classes.js, line 513

# NoFlush()

Sets non-flush mode on next TCP write.

View Source doc/classes.js, line 524

# ReadByte() → {number}

Get the next byte from the socket as number.

View Source doc/classes.js, line 488

the next byte from the socket.
number

# ReadBytes(len) → {Array.<number>}

Return data as array of numbers. This method blocks until 'len' bytes have been read.
Parameters:
Name Type Description
len number number of bytes to read from socket.

View Source doc/classes.js, line 586

data as array.
Array.<number>

# ReadLine() → {string}

Return the next line from the socket as string. This method blocks until a newline is read.

View Source doc/classes.js, line 566

the next line from the socket as string.
string

# ReadString(len) → {string}

Return data as string. This method blocks until 'len' bytes have been read.
Parameters:
Name Type Description
len number number of bytes to read from socket.

View Source doc/classes.js, line 576

data as string.
string

# WaitFlush()

Wait until all written data is flushed.

View Source doc/classes.js, line 476

# WaitInput(timeoutopt)

Wait on socket for incoming data with timeout.
Parameters:
Name Type Attributes Default Description
timeout boolean <optional>
1 max wait time.

View Source doc/classes.js, line 482

# WriteByte(ch)

write a byte to a socket.
Parameters:
Name Type Description
ch number the byte to write.

View Source doc/classes.js, line 495

# WriteBytes(data)

send binary data.
Parameters:
Name Type Description
data Array.<number> data to write as number array.

View Source doc/classes.js, line 501

# WriteString(str)

send string.
Parameters:
Name Type Description
str string data to send.

View Source doc/classes.js, line 507