[id] = OpenConnection(id, server$, port[, table])
server$. This can be either a host name or an IP address directly. The third argument specifies the port at which
OpenConnection()should try to connect. In the first argument, you need to pass an identifier which is needed to refer to this connection later on. Alternatively, you can pass Nil as the first argument. In that case,
OpenConnection()will select a vacant identifier automatically and return it to you.
Once the connection is successfully established, you can use SendData() and ReceiveData() to communicate with the server. When you are finished you should call CloseConnection() to disconnect from the server.
Please note that scheme prefixes like "http://" or "ftp://" are not part of a
server name. These just specify the protocol that is used to communicate
with the server. So if you want to connect http://www.airsoftsoftwair.de
you will have to specify "www.airsoftsoftwair.de" as the server name and
80 as the port because 80 is the standard HTTP port. See below for an
example. An exception to this rule might be the case where you use the
Adapter tag to have a network adapter establish the connection. In that
case, the network adapter might ask you to specify a scheme name like
"http://" or "ftp://" but it really depends on the network adapter. Hollywood's
inbuilt adapter doesn't support scheme prefixes and expects you to specify
the IP address or the host name directly.
Starting with Hollywood 8.0,
OpenConnection() accepts an optional table
argument that can be used to specify further options. The following
tags are currently recognized by the optional table argument:
#IPV6is currently unsupported on AmigaOS and compatible systems.
Protocol tag defaults to the default protocol type set using
SetNetworkProtocol(). By default, this is
#IPV4 due to historical and portability reasons. See SetNetworkProtocol for details.
default. See Loaders and adapters for details. (V8.0)
Trueto request a connection through TLS/SSL encryption. Note that setting this tag when using Hollywood's inbuilt network adapter doesn't have any effect because Hollywood's inbuilt network adapter doesn't support TLS/SSL connections. However, there might be a network adapter provided by a plugin that supports TLS/SSL and if you set this tag to
TrueHollywood will forward your wish to have a TLS/SSL connection to the network adapter provided by the plugin. (V8.0)
OpenConnection(1, "www.airsoftsoftwair.de", 80) SendData(1, "GET http://www.airsoftsoftwair.de/index.html " .. "HTTP/1.0\r\n\r\n") a$ = ReceiveData(1, #RECEIVEALL) Print(a$) CloseConnection(1)The code above connects to http://www.airsoftsoftwair.de and downloads the index HTML page.