socket: Network connections
This module supports creating TCP clients that create stream-based network connections to other computers or processes. In this context, the term socket refers to IPv4 stream sockets only.
See also: Use the serversocket module to create TCP servers.
- class Socket(destination as Str, port as Int[, buffering as Constant])
- Construct a TCP/IP connection stream to the specified port of the destination host. The destination may be either a host name such as "www.host.com" or a numeric IP address such as "188.8.131.52" (in decimal).
Socket instances are also implicitly created by the serversocket::ServerSocket class.
Socket inherits most of the Stream operations unchanged, including:
It also supports the following operations:
- Close the connection. Free any resources allocated to the connection.
- localAddress() as Str
- Return the local IP address as a string in dotted decimal format (e.g. "184.108.40.206").
- localPort() as Int
- Return the local port number.
- remoteAddress() as Str
- Return the remote IP address as a string in dotted decimal format (e.g. "220.127.116.11").
- remotePort() as Int
- Return the remote port number.
- GetHostByName(name as Str) as Str
- Return the IP address of a host. The name argument may be a host name or a numeric IP address in dotted decimal format. If the host has multiple interfaces, only the address of the first interface is returned.
- GetHostByAddress(address as Str) as Str
- Return the primary host name of the machine with the given IP address. The IP address must be a string in dotted decimal format.
- GetHostName() as Str
- Return a string containing the hostname of the machine where the program is running.