Members
# inner SOCKET
socket mode definition.
Properties:
Name | Type | Description |
---|---|---|
MODE.BINARY |
* | binary data stream |
MODE.ASCII |
* | ascii data stream |
MODE.CHKS |
* | use UDP checksum (default) |
MODE.NOCHK |
* | no UDP checksum |
MODE.NAGLE |
* | Nagle's algorithm |
MODE.NONAGLE |
* | don't use Nagle's algorithm |
TYPE.TCP_CLIENT |
* | tcp client socket |
TYPE.TCP_SERVER |
* | tcp server socket |
TYPE.UDP |
* | udp socket |
UDP.ANY |
* | receives any packet, outgoing packets are broadcast. |
UDP.FIRST |
* | No packets may be sent until a packet has been received. This first fills in the remote IP address and port number. |
SERVER.ANY |
* | TCP server socket bind address for any local ip address. |
Methods
# inner GetLocalIpAddress() → {IpAddress}
get the local IP address.
the local IP address as an array of numbers
# inner http_get(url, head) → {HTTPResult}
do a HTTP GET request and return the answer as array.
Parameters:
Name | Type | Description |
---|---|---|
url |
string | the URL to retrieve, must start with "http://". |
head |
Array.<string> | an array containing extra header fields and their values. Only fields defined in that array will be send with the request, no extra headers will be added. |
an array containing the HTTP response code, message, header (as string) and the response body (as an array of integer, one int per byte).
# inner http_headers(res) → {Object}
extract all response headers.
Parameters:
Name | Type | Description |
---|---|---|
res |
HTTPResult | The array returned from http_get(). |
a dictionary with header->value mapping or null if res was invalid.
Object
# inner http_ok(res) → {bool}
check if a HTTP request succeeded.
Parameters:
Name | Type | Description |
---|---|---|
res |
HTTPResult | The array returned from http_get(). |
TRUE is the request returned code 200.
bool
# inner http_string_content(res) → {string}
convert the data array returned by http_get() into a string.
Parameters:
Name | Type | Description |
---|---|---|
res |
HTTPResult | The array returned from http_get() |
a string or null if res was invalid.
string
# inner Resolve(host) → {IpAddress}
look up a hostname in DNS.
Parameters:
Name | Type | Description |
---|---|---|
host |
string | the hostname. |
The IP address of the host or an exception.
# inner ResolveIp(host) → {string}
reverse look up a host in DNS.
Parameters:
Name | Type | Description |
---|---|---|
host |
IpAddress | the ip address. |
The name of the host or an exception.
string
# inner ServerSocket(host, lport) → {Socket}
create a server socket.
Parameters:
Name | Type | Description |
---|---|---|
host |
IpAddress | string | hostname/IP-address to bind to. SOCKET.SERVER.ANY to bind to 0.0.0.0 |
lport |
number | local port to listen for incoming connections. |
A server socket.