Methods
# Close(doFlushopt)
close the socket.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
doFlush |
boolean |
<optional> |
false | flush before close. |
# DataReady() → {number}
Get number of bytes waiting to be read.
number of bytes waiting to be read.
number
# Established() → {boolean}
Check if the socket connection is established.
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. |
# Mode(mode)
Set binary or ascii mode for UDP/TCP sockets.
Parameters:
Name | Type | Description |
---|---|---|
mode |
number | one of SOCKET.MODE. |
# ReadByte() → {number}
Get the next byte from the socket as number.
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. |
data as array.
Array.<number>
# ReadLine() → {string}
Return the next line from the socket as string.
This method blocks until a newline is read.
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. |
data as string.
string
# WaitInput(timeoutopt)
Wait on socket for incoming data with timeout.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
timeout |
boolean |
<optional> |
1 | max wait time. |
# WriteByte(ch)
write a byte to a socket.
Parameters:
Name | Type | Description |
---|---|---|
ch |
number | the byte to write. |
# WriteBytes(data)
send binary data.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array.<number> | data to write as number array. |