Module

tcpip

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 CurlExtractHeaders(res) → {Object}

extract all response headers.

Parameters:
Name Type Description
res CurlResult

The array returned from Curl.DoRequest().

See:

a dictionary with header->value mapping.

Object

# inner GetDomainname() → {string}

get the domain name.

the domain name

string

# inner GetHostname() → {string}

get the hostname.

the hostname

string

# inner GetLocalIpAddress() → {IpAddress}

get the local IP address.

the local IP address as an array of numbers

IpAddress

# inner GetNetworkMask() → {IpAddress}

get the netmask.

the netmask as an array of numbers

IpAddress

# inner http_get(url, head) → {HTTPResult}

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.

Deprecated:
  • use Curl() instead! do a HTTP GET request and return the answer as array.
See:

an array containing the HTTP response code, message, header (as string) and the response body (as an array of integer, one int per byte).

HTTPResult

# inner http_headers(res) → {Object}

Parameters:
Name Type Description
res HTTPResult

The array returned from http_get().

Deprecated:
  • use Curl() instead! extract all response headers.
See:

a dictionary with header->value mapping or null if res was invalid.

Object

# inner http_ok(res) → {bool}

Parameters:
Name Type Description
res HTTPResult

The array returned from http_get().

Deprecated:
  • use Curl() instead! check if a HTTP request succeeded.
See:

TRUE is the request returned code 200.

bool

# inner http_string_content(res) → {string}

Parameters:
Name Type Description
res HTTPResult

The array returned from http_get()

Deprecated:
  • use Curl() instead! convert the data array returned by http_get() into a string.
See:

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.

IpAddress

# inner ResolveIp(ip) → {string}

reverse look up a host in DNS.

Parameters:
Name Type Description
ip 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.

Socket

# inner Socket(host, rport, lportopt) → {Socket}

Create a TCP client socket (outgoing connection).

Parameters:
Name Type Attributes Description
host IpAddress | string

IP or host name to connect to

rport number

remote port.

lport number <optional>

local port.

A TCP client socket.

Socket

# inner UdpSocket(host, rport, lportopt) → {Socket}

Create a UDP socket.

Parameters:
Name Type Attributes Description
host IpAddress | string

IP or host name to receive from or one of SOCKET.UDP.

rport number

remote port.

lport number <optional>

local port.

An UDP socket.

Socket

# inner urldecode(str) → {string}

URL decode a string.

Parameters:
Name Type Description
str string

encoded string

decoded string.

string

# inner urlencode(str) → {string}

URL encode a string.

Parameters:
Name Type Description
str string

decoded string

encoded string.

string

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 CurlExtractHeaders(res) → {Object}

extract all response headers.

Parameters:
Name Type Description
res CurlResult

The array returned from Curl.DoRequest().

See:

a dictionary with header->value mapping.

Object

# inner GetDomainname() → {string}

get the domain name.

the domain name

string

# inner GetHostname() → {string}

get the hostname.

the hostname

string

# inner GetLocalIpAddress() → {IpAddress}

get the local IP address.

the local IP address as an array of numbers

IpAddress

# inner GetNetworkMask() → {IpAddress}

get the netmask.

the netmask as an array of numbers

IpAddress

# inner http_get(url, head) → {HTTPResult}

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.

Deprecated:
  • use Curl() instead! do a HTTP GET request and return the answer as array.
See:

an array containing the HTTP response code, message, header (as string) and the response body (as an array of integer, one int per byte).

HTTPResult

# inner http_headers(res) → {Object}

Parameters:
Name Type Description
res HTTPResult

The array returned from http_get().

Deprecated:
  • use Curl() instead! extract all response headers.
See:

a dictionary with header->value mapping or null if res was invalid.

Object

# inner http_ok(res) → {bool}

Parameters:
Name Type Description
res HTTPResult

The array returned from http_get().

Deprecated:
  • use Curl() instead! check if a HTTP request succeeded.
See:

TRUE is the request returned code 200.

bool

# inner http_string_content(res) → {string}

Parameters:
Name Type Description
res HTTPResult

The array returned from http_get()

Deprecated:
  • use Curl() instead! convert the data array returned by http_get() into a string.
See:

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.

IpAddress

# inner ResolveIp(ip) → {string}

reverse look up a host in DNS.

Parameters:
Name Type Description
ip 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.

Socket

# inner Socket(host, rport, lportopt) → {Socket}

Create a TCP client socket (outgoing connection).

Parameters:
Name Type Attributes Description
host IpAddress | string

IP or host name to connect to

rport number

remote port.

lport number <optional>

local port.

A TCP client socket.

Socket

# inner UdpSocket(host, rport, lportopt) → {Socket}

Create a UDP socket.

Parameters:
Name Type Attributes Description
host IpAddress | string

IP or host name to receive from or one of SOCKET.UDP.

rport number

remote port.

lport number <optional>

local port.

An UDP socket.

Socket

# inner urldecode(str) → {string}

URL decode a string.

Parameters:
Name Type Description
str string

encoded string

decoded string.

string

# inner urlencode(str) → {string}

URL encode a string.

Parameters:
Name Type Description
str string

decoded string

encoded string.

string