Exchanging Data With Remote Hosts; Establishing A Simple Http Connection - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide
To upload local file and folders to a remote location (or download specific remote files to a local
destination) using the FTP or WebDAV protocol, use the copy or move function of an FTP object or
DAV object.
You can specify the local or remote destination of the operation as an object, as an absolute path, or as
a URL.
The FTP and DAV objects use the same error mechanism as the file object.

Exchanging Data with Remote Hosts

The
socket Object
You can exchange documents and data with another Adobe process anywhere on the Internet, simply by
writing and executing JavaScript programs on both sides.
The socket object provides methods to establish and terminate ( open and close ) a connection to a
remote computer over a TCP/IP network or the Internet, and to read and write data over that
connection. You can also use the socket object to establish a simple Internet server, using the listen
method to connect to a port, and poll to check for incoming connections on that port.
The
open
but once you have used one, you cannot use the other. When you have finished with a connection, use
to terminate it. (Deleting the socket object also terminates any open connections, but it remains
close
open until the object is actually garbage collected, so it might stay open longer than you want unless you
terminate it explicitly.)
Often, the remote endpoint terminates the connection after transmitting data. To check for this, the socket
object has a connected property that is true as long as the connection still exists. If
connected=false , the connection is closed automatically.
Use the
read
send data. If I/O errors occur, the error property contains a short message describing the type of the
error.

Establishing a simple HTTP connection

A connection can exchange simple ASCII data, or use a more complex protocol, like FTP, that involves
binary data. One of the simplest protocols is HTTP. This sample TCP/IP client connects to a web server that
listens on port 80. It sends a simple HTTP GET request to obtain the home page, then reads the reply:
reply = "";
conn = new Socket;
// access Adobe's home page
if (conn.open ("www.adobe.com:80")) {
// send a HTTP GET request
conn.write ("GET /index.html HTTP/1.0\n\n);
// read the server's reply
reply = conn.read();
conn.close();
}
After executing this code, the variable reply contains the contents of the Adobe home page together with
an HTTP response header.
allows you connect to any server on the Internet and exchange data with that server.
and
methods are mutually exclusive; you can establish a connection with either method,
listen
and
methods to read data from an open connection. Use
readln
Adobe GoLive CS2 SDK
Managing Files and Folders
and
to
write
writeln
134

Advertisement

Table of Contents
loading

Table of Contents