IBM introduced TCP/IP protocol on the AS/400 with OS/400 V3R2. Still today, however, this protocol remains underutilized even though many iSeries TCP/IP applications have been added, including a Dynamic Host Configuration Protocol (DHCP) server and a Domain Name System (DNS) server. Today, the iSeries supports many TCP/IP applications you may not be aware of. In this article, we'll look at some of these applications and explore how to make the most of TCP/IP.
Your TCP/IP Configuration
Before we examine the TCP/IP "goodies," let's look at
some of the components of your TCP/IP configuration. Navigate to the Configure
TCP/IP menu by typing the command CFGTCP. Figure 1 shows the menu that is
displayed.
Figure 1: This menu contains the options to
configure TCP/IP. (Click images to enlarge.)
Option 1 displays the Work with TCP/IP Interfaces
display, which is used to configure options related to each interface. When you
modify interfaces through this display, you'll see the screen shown in Figure
2.
Figure 2: Use this screen to modify a TCP/IP
interface.
On this screen, the Line Description can contain either
the name of a previously created line description or special values *VIRTUALIP,
*OPC, or *LOOPBACK. One unusual capability when creating a TCP/IP interface on
the iSeries is that you can define two unique IP addresses to a single Ethernet
adapter. This means that you can actually have your iSeries accessible to two
distinct and separate subnets. Figure 3 illustrates this using the Work with
TCP/IP Interfaces display.
Figure 3: A single iSeries Ethernet line can be assigned multiple IP
addresses.
Notice that IP addresses 90.0.0.3 and 192.168.50.11 are
both assigned to line ETHLINE. Based on the subnet masking shown, an IP address
in the range of 90.0.0.1 through 90.254.254.254 will be able to access the
system through address 90.0.0.3. Again, based on the subnet mask defined, any
computer with an IP address in the range of 192.168.50.1 through 192.168.50.254
will have access to the system through IP address 192.168.50.11. Option 2 on
this menu defines TCP/IP routes to other networks. If, for example, your iSeries
existed on a TCP/IP network 192.168.50.0 with a subnet mask of 255.255.255.0 and
you needed to give iSeries access to a network 192.168.51.0 with a subnet mask
of 255.255.255.0, which is accessed through a router with an IP address of
192.168.50.254, you would use the ADDTCPRTE command to add a route for this
network:
SUBNETMASK('255.255.255.0')
NEXTHOP('192.168.50.254')
Alternatively, if the iSeries was in TCP/IP network 192.168.50.0 with a
proxy server at IP address 192.168.50.1, you could configure the iSeries to
allow Internet access by creating a default route using this command:
SUBNETMASK('*NONE')
NEXTHOP('192.168.50.1')
TCP/IP port restrictions are defined through option 4 on the CFGTCP menu.
You can use this screen to restrict access to specific TCP/IP services by user.
Figure 4 shows the Work with TCP/IP Port Restrictions display.
Figure 4: With port restrictions, you can control access to a
specific TCP/IP application.
You can specify a lower and upper port
number as well as whether the application is TCP or UDP protocol. If a port
restriction is created for a given port or range of ports, only the user
specified will have access to the defined port or ports. In the example above,
the user MFAUST will be the only one with access to ports 20 and 21, which are
generally used for the FTP service. This leads us to the topic of TCP/IP
applications.
iSeries TCP/IP Applications
The iSeries has a complete set of standard TCP/IP
applications, yet I'm constantly amazed by how underutilized those applications
are in most iSeries shops. The following table contains a list of the standard
TCP/IP applications on the iSeries. Many of these applications will look
familiar. Others may not.
Service/Application
|
Description
|
FTP
|
File Transfer Protocol. Used to send and receive files to and from an
iSeries.
|
TELNET
|
Terminal emulation protocol used to log into the iSeries or remote systems.
|
HTTP
|
Hypertext Transfer Protocol. Used by Internet browser-based
applications.
|
DNS
|
Domain Name Service. Used to keep track of server names and associated IP
addresses.
|
DHCP
|
Dynamic Host Configuration Protocol. Used to automatically configure TCP/IP
network clients based on parameters defined on the DHCP server.
|
POP
|
Post Office Protocol. Used to retrieve email from an Internet mail
server.
|
SNMP
|
Simple Network Management Protocol. Allows TCP/IP-based devices (computers,
printers, routers) to be monitored using a single protocol.
|
SMTP
|
Simple Mail Transfer Protocol. Also used for email purposes, generally used
to send messages to an Internet mail server.
|
REXEC
|
Remote execution command protocol. Allows commands to be issued from a
client to execute on the server.
|
BOOTP
|
Bootstrap Protocol. Similar to DHCP. Used to assign IP addresses to
network-connected devices.
|
LPD
|
Line Printer Daemon protocol. The TCP/IP standard for sending data to a
network-connected printer within a TCP/IP network.
|
FTP
FTP is commonly used to download files from Internet
Web sites. What you may not know is that you can also use FTP to execute
commands and call programs on the iSeries. This is extremely useful when you
want to create a process that will run a program on the iSeries to create a data
file to be downloaded. Here's an example:
mfaust
secret
quot RCMD ADDLIBLE QTEMP
quot RCMD ADDLIBLE MYLIB
quot RCMD CALL BLDFTPDTA
get ftpfile.ftpmbr ftpfile.txt
quit
This sample FTP script starts by connecting to the system at IP address
192.168.50.11. The next two lines send the user name and password to be used to
log into the system. Next, the FTP command QUOT is used with the ADDLIBLE
command to add any required libraries to the current FTP session's library list.
The QUOT FTP command allows us to run OS/400 commands from an FTP session. The
FTP session works much like a Client Access 5250 session or Telnet session in
that, when you log in, your session receives a default library list that is
currently defined on the QFTP job description. Any libraries added to this
library list (as in the example) will remain in the session library list until
the session is logged out or ended. The next command in the script again uses
the QUOT command to execute the command CALL BLDFTPDTA, which would be a program
to build the data to be downloaded. Then, the FTP command "get ftpfile.ftpmbr
ftpfile.txt" retrieves the contents of the physical file named ftpfile with the
physical file member named ftpmbr into the PC file ftpfile.txt. Finally, the
quit command ends the FTP session.
This technique could be modified
slightly to send data to the iSeries and then run a program to process the data
sent. This would be done by first replacing the "get" command with a "send
ftpfile.txt ftpfile.ftpmbr" command and then moving the QUOT CALL command to
after the new send command. You can execute this script from a Windows-based PC
client by using the FTP command's –S option:
Telnet
Telnet protocol is used by within the Personal
Communications portion of iSeries Access for Windows for terminal emulation
purposes. What you may not realize is that most other terminal emulators will
also allow you to access an interactive display session on the iSeries. To do
this from a Windows workstation, simply go to a command prompt and type
this:
When this statement is executed, a connection will be attempted to the
specified IP. Since the destination system is an iSeries, an iSeries sign-on
screen will be displayed for this IP address (Figure 5).
Figure 5: A sign-on display from a Telnet session looks like
this.
The drawback to using the Windows Telnet client for this type
of connection is that the keyboard mapping does not conform to iSeries
standards. This means that function keys and other control keys have to be sent
using unusual key sequences. "Roll up," for example, is achieved by pressing
CTRL+U, while CTRL+D is "Roll down." The current key mapping info can be viewed
via the DSPVTMAP command when signed into the iSeries from a VT100 Telnet
client. The following table shows the standard keyboard mappings.
Standard Keyboard Mappings
|
|||
5250 Function
|
VT Key(s)
|
5250 Function
|
VT Key(s)
|
5250 Attention
|
CTRL-A or ESC+A
|
Redraw Screen
|
CTRL-L or ESC+L
|
5250 Help
|
CTRL-? Or ESC+H
|
F1
|
ESC-1 or F1
|
Page Down (Roll Up)
|
CTRL-D or CTRL-F
|
F2
|
ESC-2 or F2
|
Page Up (Roll Down)
|
CTRL-B or CTRL-U
|
F3
|
ESC-3 or F3
|
System Request
|
CTRL-C or ESC+S
|
F4
|
ESC-4 or F4
|
Insert
|
ESC+I or ESC+DEL or INSERT
|
F5
|
ESC-5
|
Delete
|
DEL
|
F6
|
ESC-6
|
Enter
|
RETURN
|
F7
|
ESC-7
|
Backspace
|
BACKSPC
|
F8
|
ESC-8
|
Duplicate
|
ESC+D
|
F9
|
ESC-9
|
Erase Input
|
CTRL-E
|
F10
|
ESC-0
|
Error Reset
|
CTRL-R or ESC+R
|
F11
|
ESC--
|
Field Exit
|
CTRL-K or CTRL-X or ESC+X
|
F12
|
ESC-=
|
Field Minus
|
ESC+M
|
F13
|
ESC-!
|
Home
|
CTRL-O
|
F14
|
ESC-@
|
New Line
|
ESC+Line Feed
|
F15
|
ESC-#
|
Print
|
CTRL-P or ESC+P
|
F16
|
ESC-$
|
Field Advance
|
TAB
|
F17
|
ESC-%
|
Field Backspace
|
ESC+TAB
|
F18
|
ESC-^
|
Cursor Up
|
Up arrow
|
F19
|
ESC-&
|
Cursor Down
|
Down Arroe
|
F20
|
ESC-*
|
Cursor Left
|
Left Arrow
|
F21
|
ESC-(
|
Cursor Right
|
Right Arrow
|
F22
|
ESC-)
|
Clear Screen
|
ESC+C
|
F23
|
ESC-_
|
Test Request
|
CTRL-T
|
F24
|
ESC-+
|
Toggle Indicator Lights
|
ESC+T
|
|
|
Despite the keyboard mapping issue, this can be useful when you need to
access the iSeries from a PC that doesn't have iSeries Access for Windows
installed. Since most "non-Windows" operating systems include a Telnet client,
this can also be an option for accessing an iSeries from a machine running Linux
or UNIX.
HTTP
HTTP is used by WebSphere and the other iSeries Web
server options (Apache, Tomcat, etc.). This has become one of the more commonly
used iSeries TCP/IP components, and with good reason. The universal appeal of
Web browser interfaces in addition to the multitude of options now available for
developing HTTP browser-based applications on the iSeries make this a great
alternative for developing iSeries applications. Conveniently, the iSeries
includes an administrative console that is (ironically enough) browser-based.
You can access this application from your Web browser through port 2001 by
navigating to http://xxx.xxx.xxx.xxx:2001/, where xxx.xxx.xxx.xxx
represents the IP address of your iSeries. Figure 6 shows the browser-based
admin tool for the iSeries Web server.
Figure 6: This is the browser-based HTTP admin console.
From
this console, you can configure Web servers as well as start and stop individual
server instances.
LPD
LPD servers not only allow iSeries printers to be
accessed from a TCP/IP client, but also allow the iSeries to access any
network-connected, TCP/IP-enabled printer, including printers connected through
general-purpose interface boxes like the HP Jetdirect printer server boxes. When
configuring these devices, you have two separate options: creating a *LAN device
description for the printer or creating a remote output queue. To configure a
device description as *LAN, the print server must support either IBM or HP
Printer Job Languages (PJL) by defining the System Driver Program (SYSDRVPGM)
parameter as either *IBMPJLDRV or *HPPJLDRV on the CRTDEVPRT command. Here's an
example:
LANATTACH(*IP) PORT(9100) FONT(11)
TRANSFORM(*YES) MFRTYPMDL(*HPPCL6)
RMTLOCNAME('192.168.50.1')
This command creates a printer device description for a LAN-attached
HP/PCL6-compatible IP printer named LPDPRT01 at IP address 192.168.50.1. Older
print server devices that do not support either of these options can also be
used for iSeries printing by using the CRTOUTQ command:
CNNTYPE(*IP) DESTTYPE(*OTHER) MFRTYPMDL(*HPLJIII)
INTNETADR('192.168.50.99')
Replace RMTQUENAME with a name identifying your printer and replace
192.168.50.99 with the IP address of your printer. You can also use the
MFRTYPMDL parameter to define the manufacturer type and model number of the
printer being defined. And you can use the RMTPRTQ option to define the name of
the specific port to which the printer is connected in the case of multi-port
printer servers. With this option, you can also specify a shared printer name
when connecting to a printer on an iSeries or Windows printer server. This is
where using the iSeries as a TCP/IP printer server comes into play. For example,
you can send a text file from a Windows-based PC to an iSeries printer using
this LPR command:
Here, xxx.xxx.xxx.xxx represents the iSeries IP address and
prtdevname represents the printer device description on the iSeries. You
can also create an LPR port that points to an iSeries printer from a
Windows-based PC. To add a generic text printer using this method, go to the
Windows control panel and select Add Printer. When the wizard is displayed,
click Next and identify that you are installing a local printer. (This may not
make sense, but Windows looks at an LPR printer device as a local printer port,
not a network printer.) Then, select the Create a New Port radio button and
choose the LPR Port option from the drop-down box. You'll see the dialog shown
in Figure 7.
Figure 7: Use this dialog when adding an LPR port to the iSeries in
Windows.
On this dialog, the first box defines the IP address of your
iSeries. The second box identifies the name of the device description for the
corresponding iSeries printer. Click OK, and the wizard will prompt you for the
device manufacturer's name and model. After you select the appropriate printer
from the provided list, your new printer will be installed.
SMTP
The iSeries also has the ability to send Internet
email messages using SMTP. The configuration requirements are minimal and begin
with using the CHGSMTPA command:
The IP address shown represents the IP address of the server used to
relay Internet email messages on your network. Next, use the ADDDIRE command to
create a gateway for sending messages to the mail server:
Finally, use the CHGDSTA command to define the route to your SMTP server:
This command uses the previously created directory entry as the route for
any SMTP email messages. Once you've made these configuration changes, you can
send messages using the SNDDST command:
DSTD('Test SMTP Message')
LONGMSG('This is a test message to illustrate how easy
it is to configure the iSeries for sending
SMTP Internet mail messages.')
After you replace the sample email address with a valid Internet email
address, the message is sent to the desired recipient.
For more
information on using the iSeries for SMTP, see The iSeries and AS/400 Programmer's
Guide to Cool Things.
These are just a few examples of the powerful
TCP/IP-based applications available. In addition to these canned applications,
you can create your own custom IP-enabled applications using the iSeries Socket
APIs. When you consider all of the IP options available, it's easy to see why
IBM put the i(Series) in TCP/IP.
Mike Faust is
an Application Programmer for Fidelity Integrated Financial Solutions in
Maitland, Florida. Mike is also the author of the books The iSeries and AS/400 Programmer's
Guide to Cool Things and Active Server Pages
Primer. You can contact Mike at
LATEST COMMENTS
MC Press Online