Copyright (c) 2012-2016 Hyperion Entertainment and contributors.
AmigaOS Manual: Network resources
A network interface configured in the Internet Preferences can be used for connecting to a remote computer and exchanging data with it. Depending on the selected network driver, you can use a modem or a network interface card for the connection.
A computer network forms when two or more computers are connected to each other so that they can exchange data. A networked computer, a node, can act as a server or a client, or both.
Server's role in the network is to provide functions or services to the client nodes. The typical servers are web and file servers: a web server returns web pages to the clients and a file server returns files. One server node can host several servers at the same time.
A node is said to be a client when it is running one or more applications which request services from server nodes. The typical client applications are web browsers and file transfer programs.
Every node has a unique numeric identifier, an IP address. The IP addresses make it possible for clients to send requests to servers and for servers to send responses to clients. For human convenience a name can be assigned to an IP address. See Internet Preferences editor's Hosts list for assigning names for LAN (Local Area Network) nodes.
|The Internet has its own name assignments for IP addresses. When you are connected to the Internet, your ISP (Internet Service Provider) provides a transparent name-to-IP-address translation for you.|
Every server has a dedicated communication channel for receiving requests and sending responses. These channels are called ports. Ports are needed for the client-server communication with the IP addresses since there can be several concurrent servers on one computer and several client applications on the client computer. Without the ports requests would not reach the intended servers and the client applications would not receive the responses.
Much like with the IP addresses, a service name can be used instead of a port number. Note however, that the service names are available only for registered ports. To see a complete list of available service names, see Internet Preferences editor's Services list.
|File Transfer Protocol (FTP)||21||ftp|
|Secure Shell (SSH)||22||ssh|
|Telnet remote login service||23||telnet|
|Simple Mail Transfer Protocol (SMTP)||25||smtp|
|Domain Name System (DNS) service||53||domain|
|Hypertext Transfer Protocol (HTTP)||80||www|
|Post Office Protocol (POP3)||110||pop3|
|Network News Transfer Protocol (NNTP)||119||nntp|
|Network Time Protocol (NTP)||123||ntp|
|Internet Message Access Protocol (IMAP)||143||imap|
|Simple Network Management Protocol (SNMP)||161||snmp|
|Internet Relay Chat (IRC)||194||irc|
|Secure Hypertext Transfer Protocol (HTTPS)||443||https|
Sending a request to a server
The TCP: device allows sending requests to the servers and receiving their responses. The procedure of the client to server communication using the TCP: device is:
- Open the TCP: device for reading and writing.
- Compose a request and write it to the device.
- Read server's response from the device.
- Close the device.
When opening the TCP: device for sending a request to a server, the following parameters are available:
|HOST or H||H=HOST||Server's IP address or server's name.|
|PORT or P||P=PORT/K||Server's port number to which the request will be send. This parameter is mutually exclusive with the SERVICE parameter.|
|SERVICE or S||S=SERVICE/K||Name of the service on the server to which the request will be sent. This parameter is mutually exclusive with the PORT parameter.|
Parameters must be separated with slash (/). For example:
OPEN( 'network', 'TCP:HOST=os4depot.net/PORT=80', 'RW' )
Every server has its own format for requests and responses; they have their own communication protocols. In the following example a web page request is sent to a web server and the response is printed to Shell.
The targeted web server is os4depot.net, port is 80, and the requested page is index.php.
Program 23: RequestWebPage.rexx
/* ** Request web page */ host = 'os4depot.net' /* Server address */ port = '80' /* Port */ resource = '/index.php' /* Path to file */ userAgent = 'Mozilla/5.0 (Amiga; AmigaOS/4.1) ARexx/36.8 (ARexx script)' /* Client application */ /* Compose HTTP request */ request.method = 'GET' /* Retrieve information */ request.uri = resource /* Path to file */ request.procolVersion = 'HTTP/1.1' /* HTTP version */ request.line = request.method || ' ' || request.uri || ' ' || request.protocolVersion request.header.host = 'Host: ' || host || ':' || port request.header.userAgent = 'User-Agent: ' || userAgent /*--- Open connection ---*/ parameters = 'HOST=' || host || '/' parameters = parameters || 'PORT=' || port if ~open( 'network', 'TCP:' || parameters, 'RW' ) then do say 'Failed to open connection.' exit 0 end /*--- Send request ---*/ writeln( 'network', request.line ) writeln( 'network', request.header.host ) writeln( 'network', request.header.userAgent ) writeln( 'network', '' ) /* End of request */ /*--- Print host response ---*/ do until eof( 'network' ) say readln( 'network' ) end /*--- Close connection ---*/ call close( 'network' )