IEXP Software
Search:
  
HOME
 |  PRODUCTS
 |  SERVICES & CONSULTING
 |  SUPPORT
 |  COMPANY
<CFX_RawSocket> Documentation
This page contains all the information a ColdFusion web developer will need to install and use CFX_RawSocket on ColdFusion Application Server. Be sure to read the System Requirements before following any of the steps of this document. It is highly recommended that you read through this whole document before you start installing the software.
  1. Downloading all the required software
  2. Installing the Java Runtime Environment (JRE)
  3. Installing Java Secure Socket Extention (JSSE)
  4. Installing CFX_RawSocket
  5. Calling CFX_RawSocket from a ColdFusion Page
  6. Writing HTTP messages


1. Downloading all the required software

If you haven't read the System Requirements yet, please review them now.

ColdFusion Application Server
This document assumes that you already have a copy of ColdFusion Application Server installed and running. If you do not have ColdFusion Server, you can download a trial version online. Macromedia also has a feature-limited version of ColdFusion Server (ColdFusion Express) that is available as a free download. Both can be downloaded here: http://www.macromedia.com/software/coldfusion/downloads/

JavaTM 2 Runtime Environment (JRE)
The Java 2 Runtime Environment (JRE) is a FREE download and gives your server the ability to load and run Java classes, and is required for ColdFusion Server to use CFX_RawSocket. As of the writing of this document, the most updated version of the Java Runtime Environment was version 1.3.1. Any release of JRE v1.2.1 or greater will work with CFX_RawSocket. The JRE can be downloaded from Sun Microsystems' site here: http://java.sun.com/j2se/1.3/jre/

Java Secure Socket Extension (JSSE)
JSSE adds the capability to the JRE to be able to talk to SSL (Secure Socket Layer) sites. For users who have Java Runtime Environment (JRE) v1.2.x or v1.3.x, JSSE is a free download from Sun Microsystems' website. As of the writing of this document, JSSE version 1.02 was the most recent release. You can download it here: http://java.sun.com/products/jsse/. In order to download JSSE, you must register for a free account on Sun's website.

NOTE: If you are running JRE version 1.4 (not released yet as of the writing of this document), JSSE is included in the JRE download, so you do not need to download it.

<CFX_RawSocket>
Download the CFX_RawSocket files by clicking here.

2. Installing the Java Runtime Environment (JRE)

The Java Runtime Environment is available for Solaris, Linux and Microsoft Windows. This document will only cover installation on Microsoft Windows platform. Installation of JRE is relatively intuitive, and if you have installed other applications on your server, installing JRE will be very easy.

For Microsoft Windows, double-click on the .exe file you downloaded from Sun Microsystems' website in the previous step. (it should be called something like j2re-1_3_1_02-win.exe) For most installations, choosing all the default options is recommended. Take note of the directory where JRE is installed, as you will need to locate it later. The directory where JRE is installed is referred to as <java-home> later in this document.

You may be required to reboot your system after installing JRE. If prompted, reboot your machine.

3. Installing Java Secure Socket Extention (JSSE)

NOTE: If you are using Java Runtime Environment v1.4 or greater, you do not need to install JSSE. You can skip this section.

JSSE is downloaded as a zip file (something like jsse-1_0_2-do.zip). In order to open this file, you must have a utility top open .zip files such as WinZip.

Once you open the .zip file, extract the files to a temporary location on your computer. In the files that you extracted from the .zip file, there is a file called INSTALL.txt which contains detailed installation instructions. This document will highlight the next steps, but refer to the INSTALL.txt document if you have any questions. To install JSSE, follow these steps:
  1. Copy the .jar files from the \lib\ directory of the JSSE files to the <java-home>\lib\ext directory of the JRE installation you did in the previous step
  2. Open the <java-home>\lib\security\java.security file in a text editor, such as notepad. Find the line that says security.provider.1=sun.security.provider.Sun (or something very similar). Add the following new line directly below this line: security.provider.2=com.sun.net.ssl.internal.ssl.Provider.

    NOTE: Each line is numbered (security.provider.n). If there is already a second line (or more), add this line after the others and number it appropriately.
The INSTALL.txt file outlines several more steps for installing JSSE. For using CFX_RawSocket, only the above steps are required.

4. Installing CFX_RawSocket

These instructions are for ColdFusion Server 5. ColdFusion Server 4.5 and ColdFusion MX are slightly different (updated documentation is coming). Once JRE and JSSE are installed, you will need to configure ColdFusion Server to tell it where to find the JRE files. You will then need to register the CFX_RawSocket class file and make it available as a custom tag.

Configure ColdFusion Server 5 and JRE
  1. Log in to ColdFusion Administrator (check ColdFusion Documentation if you are not familiar with this)
  2. Click on "JVM and Java Settings" in the left navigation bar
  3. The first item on this screen tells ColdFusion where to find the JRE files you installed. Click on "Browse Server" and select the
    <java-home>\bin\hotspot\jvm.dll file. (screen shot)
Install CFX_RawSocket
  1. Copy the CFX_RawSocket.class file (from the CFX_RawSocket download) into the C:\CFUSION\Java\classes directory on your server.

    NOTE: You can install the .class file in a different directory on your server, but you will need to add that directory to the "Class Path" so that the Java JVM knows where to look for it.

  2. In ColdFusion Administrator, click on "CFX Tags" in the left navigation bar.
  3. In the page that opens, click on "Register Java CFX".
  4. For tag name, type "CFX_RAWSOCKET"
  5. For class name, type "CFX_RawSocket"
  6. For Description, type "IEXP Java Raw Socket Custom Tag"
  7. Click on "Submit Changes"
5. Calling CFX_RawSocket from a ColdFusion Page

Once you have completed the above steps, the CFX_RawSocket tag should be available to any ColdFusion pages you have on your server. To use CFX_RawSocket, use the following tag syntax:

  <CFX_RAWSOCKET
      server="host.domain.com"
      port="80|443|Other"
      protocol="HTTP|HTTPS|Other"
      message="GET / HTTP/1.0"
      responsevar="SocketOutput">

Tag Attributes:
server This attribute should be the fully qualified host name or IP address of the host you are contacting. i.e. "www.iexp.com" or "209.195.206.10"
port This attribute specifies the numeric port that you are contacting on the remote server. Use "80" for standard HTTP, "443" for SSL.
protocol This attribute specifies whether you are using "HTTP", "HTTPS", or "Other".
message This attribute is the exact message you want to send to the server. This must be a complete message that you create (see next section).
responsevar This attribute specifies the name of the ColdFusion variable that you want the response from the server to be stored in.

6. Writing HTTP messages

In order to fully utilize CFX_RawSocket to talk to HTTP and HTTPS servers, you need to know a little bit about writing your own HTTP messages. Basic HTTP message syntax will be covered here. For painfully detailed information on writing HTTP messages, please refer to the complete specification on HTTP 1.1 online here: http://www.w3.org/Protocols/rfc2616/rfc2616.html.

The Basics
When sending a message to a server, you will need to construct the full message (including any required headers) before you can get anything back from the remote server. Typically HTTP GET messages are 1 or two lines, and HTTP POST messages are multi-line (all lines are separated by carriage-return and line feed characters, or "#chr(13)##chr(10)#" in CFML).

The GET Method
The GET method is simply for retrieving a file from an HTTP server. When you type in a web address in your web browser, your browser sends a GET message to the remote server. The basic syntax for a GET message is:

    GET /document.html HTTP/1.0

For example, to retrieve the front page of a website, the message would be:

    GET / HTTP/1.0

In HTTP/1.1, the host name is required in the request. For example, to retrieve the front page of www.verisign.com using HTTP/1.1, the message would be:

    GET / HTTP/1.1
    Host: www.verisign.com

A port number is not required in HTTP/1.0, and is optional in HTTP/1.1. If not specified, the port is always assumed to be port 80, which is the standard HTTP port number. If you are using HTTP/1.1 and requesting a document from a server using a different port number, you must specify the port after the host name like this:

    GET / HTTP/1.1
    Host: www.verisign.com:80

The POST Method
The POST method is used for sending data to the server, with which a response based on that information is expected back. POST messages are considerably more complex than GET messages, and only the basic syntax will be covered here. If you need more detailed information, please see the HTTP reference document above.

The POST syntax for HTTP/1.0 is the following:

    POST /form-action.cfm HTTP/1.0
    Content-Length: 100
    Content-type: application/x-www-form-urlencoded
    Accept: */*
    urlencoded message here

The file specified right after the "POST" in this message is the page or script that you are "posting" data to. The "Content-Length" value should be the the length of your "url encoded message". The "url encoded message" format will vary depending on what your page or script is expecting to receive.

The same message in HTTP/1.1 includes the Host header like the following:

    POST /form-action.cfm HTTP/1.1
    Host: www.mysite.com:80
    Content-Length: 100
    Content-type: application/x-www-form-urlencoded
    Accept: */*
    urlencoded message here



Document Updated 03/19/2002
Introduction
Requirements
Documentation
Support
Download It (free!)

FusionDox 2.5
Knowledge in Motion - ColdFusion Document Management Software
>>More Information
FastPage 3
Low-cost, easy-to-use content management. No programming is required to update page content!
>>More Information

Professional web hosting by people who know ColdFusion and JRun. Period. Our customer service blows away the competition.
>>More Information
Lightweight, High-Strength e-Commerce
IEXP's e-Commerce engine was designed from the bottom-up using ColdFusion and is fast, efficient, highly customizeable and easy to use.
>>More Information
  Privacy Contact Us