Cross-platform TCP/IP Socket Programming in REXX



Similar documents
E-Commerce Security. The Client-Side Vulnerabilities. Securing the Data Transaction LECTURE 7 (SECURITY)

Course Description and Outline. IT Essential II: Network Operating Systems V2.0

Fundamentals of UNIX Lab Networking Commands (Estimated time: 45 min.)

Basic Networking Concepts. 1. Introduction 2. Protocols 3. Protocol Layers 4. Network Interconnection/Internet

1 Data information is sent onto the network cable using which of the following? A Communication protocol B Data packet

Socket = an interface connection between two (dissimilar) pipes. OS provides this API to connect applications to networks. home.comcast.

Understanding TCP/IP. Introduction. What is an Architectural Model? APPENDIX

Basic Operation & Management of TCP/IP Networks

Chapter 6 Configuring the SSL VPN Tunnel Client and Port Forwarding

TCP/IP, Addressing and Services

First Workshop on Open Source and Internet Technology for Scientific Environment: with case studies from Environmental Monitoring

Internetworking and IP Address

TCP/IP Networking An Example

File Transfer Protocol (FTP) Chuan-Ming Liu Computer Science and Information Engineering National Taipei University of Technology Fall 2007, TAIWAN

Firewall VPN Router. Quick Installation Guide M73-APO09-380

Basic Network Configuration

My FreeScan Vulnerabilities Report

OS/390 Firewall Technology Overview

BASIC ANALYSIS OF TCP/IP NETWORKS

Agenda. Distributed System Structures. Why Distributed Systems? Motivation

A Heterogeneous Internetworking Model with Enhanced Management and Security Functions

A host-based firewall can be used in addition to a network-based firewall to provide multiple layers of protection.

TCP/IP Fundamentals. OSI Seven Layer Model & Seminar Outline

Network-Oriented Software Development. Course: CSc4360/CSc6360 Instructor: Dr. Beyah Sessions: M-W, 3:00 4:40pm Lecture 2

Device Log Export ENGLISH

Connecting with Computer Science, 2e. Chapter 5 The Internet

EXPLORER. TFT Filter CONFIGURATION

How To Use A Network Over The Internet (Networking) With A Network (Netware) And A Network On A Computer (Network)

2- Electronic Mail (SMTP), File Transfer (FTP), & Remote Logging (TELNET)

TCP/UDP # General Name Short Description

Multi-Homing Dual WAN Firewall Router

SO114 - Solaris 10 OE Network Administration

Lab - Observing DNS Resolution

Virtual Server and DDNS. Virtual Server and DDNS. For BIPAC 741/743GE

Remote login (Telnet):

Chakchai So-In, Ph.D.

Writing Client/Server Programs in C Using Sockets (A Tutorial) Part I. Session Greg Granger grgran@sas. sas.com. SAS/C & C++ Support

This document explains how to configure and use the IOPRINT+ Print Server in the Unix TCP/IP environment.

Software installation and configuration IEC-line series

Network Layers. CSC358 - Introduction to Computer Networks

1 Introduction: Network Applications

Data Communication Networks and Converged Networks

Chapter 6 Virtual Private Networking Using SSL Connections

Stateful Inspection Technology

Introduction to Computer Networks

Chapter 6. About This Chapter. Before You Begin. Windows 2000 Naming Schemes. [Previous] [Next]

3.1 RS-232/422/485 Pinout:PORT1-4(RJ-45) RJ-45 RS-232 RS-422 RS-485 PIN1 TXD PIN2 RXD PIN3 GND PIN4 PIN5 T PIN6 T PIN7 R+ PIN8 R-

1. The Web: HTTP; file transfer: FTP; remote login: Telnet; Network News: NNTP; SMTP.

z/os Firewall Technology Overview

Technical Support Information Belkin internal use only

Internet Security [1] VU Engin Kirda

finger, ftp, host, hostname, mesg, rcp, rlogin, rsh, scp, sftp, slogin, ssh, talk, telnet, users, w, walla, who, write,...

Specialized Programme on Internetworking Design and LAN WAN Administration

Slide 1 Introduction cnds@napier 1 Lecture 6 (Network Layer)

HomeWorks P5 Processor Ethernet TCP / IP Networking Specification

UNIX: Introduction to TELNET and FTP on UNIX

Procedure: You can find the problem sheet on Drive D: of the lab PCs. 1. IP address for this host computer 2. Subnet mask 3. Default gateway address

Lab - Observing DNS Resolution

Networking Security IP packet security

Lecture (02) Networking Model (TCP/IP) Networking Standard (OSI) (I)

Linux MDS Firewall Supplement

DB2 Connect for NT and the Microsoft Windows NT Load Balancing Service

Ethernet. Ethernet. Network Devices

Course Overview: Learn the essential skills needed to set up, configure, support, and troubleshoot your TCP/IP-based network.

Volume SYSLOG JUNCTION. User s Guide. User s Guide

Internetworking Microsoft TCP/IP on Microsoft Windows NT 4.0

Domain Name Resolver (DNR) Configuration

PolyServe Understudy QuickStart Guide

OSBRiDGE 5XLi. Configuration Manual. Firmware 3.10R

Understanding Layer 2, 3, and 4 Protocols

The Application Layer. CS158a Chris Pollett May 9, 2007.

Transport and Network Layer

BR Load Balancing Router. Manual

Client-server systems

User s Manual TCP/IP TO RS-232/422/485 CONVERTER. 1.1 Introduction. 1.2 Main features. Dynamic DNS

OVERVIEW OF TYPICAL WINDOWS SERVER ROLES

How To Connect To Bloomerg.Com With A Network Card From A Powerline To A Powerpoint Terminal On A Microsoft Powerbook (Powerline) On A Blackberry Or Ipnet (Powerbook) On An Ipnet Box On

Network: several computers who can communicate. bus. Main example: Ethernet (1980 today: coaxial cable, twisted pair, 10Mb 1000Gb).

Introduction To Computer Networking

Network Models and Protocols

1 hours, 30 minutes, 38 seconds Heavy scan. All scanned network resources. Copyright 2001, FTP access obtained

Objectives of Lecture. Network Architecture. Protocols. Contents

Network Pop Quiz 5 Brought to you by please visit our site!

Load Balancer LB-2. User s Guide

Computer Networks/DV2 Lab

LifeSize Video Communications Systems Administrator Guide

Chapter 5. Data Communication And Internet Technology

Guideline for setting up a functional VPN

Application. Transport. Network. Data Link. Physical. Network Layers. Goal

Date 07/05/ :20:22. CENTREL Solutions. Author. Version Product XIA Configuration Server [ ]

P and FTP Proxy caching Using a Cisco Cache Engine 550 an

Configuration Guide. BlackBerry Enterprise Service 12. Version 12.0

Division of Informatics, University of Edinburgh

File Transfer Examples. Running commands on other computers and transferring files between computers

The OSI and TCP/IP Models. Lesson 2

Transcription:

Cross-platform TCP/IP Socket programming in REXX Abstract: TCP/IP is the key modern network technology, and the various REXX implementations have useful, if incompatible interfaces to it. In this session, we cover writing TCP/IP clients and servers in REXX, on MVS, Win32, and UNIX platforms, and propose a workable solution to the incompatibility issues Bob Stark bstark@protechtraining.com 412-445-8072 1 Contents TCP/IP Networking Review Socket Programming Overview Sample TCP/IP Socket Application 2 1

TCP/IP Application Functionality Via TCP/IP users may: Use terminal access to other systems (Telnet) Send commands to other systems and receive responses Transfer and share files between systems (FTP and NFS) Use devices on other systems (Printing) Enable cross-platform communication between cooperating applications 3 Two Similar Packet Delivery Systems FROM: ProTech One Monroeville Center, Suite 622 Monroeville, PA 15146 TO: You Your Company Your street address Your city, State, zipcode Ethernet frame: TO: 00:23:44:31:A1:19 FROM:00:23:44:38:F1:D4 DATA: IP packet: TO: 192.168.1.20 PORT: 21 FROM:192.168.1.252 PORT: 1019 DATA: Your data goes here 4 2

Packet Routing Post Office Post Office Mail Room 5 Packet Routing Internet Gateway Internet Backbone Internet Gateway LAN Server LAN Server Dial Backup Router Workgroup Web Server Mainframe 6 3

Network Physical Layer, IP Layer Physical layer Ethernet is the most common physical network type in use today (others include ATM, FDDI, Token Ring) Each Ethernet card contains a unique hardware address, burned into it by the manufacturer IP Addressing Every network interface card (NIC) gets an IP Address Forms a network of interconnected networks Example: Host: 209.161.92.101 (rexxdog.protechpts.com) Net Mask: 255.255.255.0 (Class C network, 254 hosts) Network: 209.161.92.0 7 Server OS/390 TCP/IP Sockets 21 ftpd 23 telnetd Client 53 dns 1281 ftp 1282 HTTP 80 http 1953 nslookup 1288 telnet 8 4

9 Well Known UDP & TCP Ports Port Application Description Echo 7/udp Echo Datagram back to sender FTP-Data 20/tcp File Transfer data transfer FTP 21/tcp File Transfer dialogue Telnet 23/tcp Telnet remote login port SMTP 25/tcp Simple Mail Transfer Protocol DNS 53/udp Domain name server HTTP 80/tcp Default Web server port POP3 110/tcp PC mail retrieval service NNTP 119/tcp Network news access NTP 123/udp Network Time Protocol SNMP 161/udp Simple Network Management queries SNMP-trap 162/udp Simple Network Management alerts TCP/IP Services ARP - Address Resolution Protocol Translates between hardware address & IP address Routers use arp to find out which machine on its network is to receive a given IP data packet DNS - Domain Name Service Translates between hostnames & IP addresses Essential for "human" use of the Internet Each domain is locally managed, i.e. ProTech gets to name the machines in protechpts.com Slow TCP/IP response often related to DNS problems nslookup - UNIX command used to query the domain name server 10 5

TCP/IP Applications telnet - Terminal emulation Allows terminal -> host connection w/o dedicated wire Terminal type and capabilities are negotiated TN3270 is telnet for 3270 terminals ftp - File Transfer Protocol Allows files to be transferred between hosts Supports transfer between dissimilar machines OS/390 (EBCDIC) to PC (ASCII) or other UNIX (ASCII) Dataset name <-> UNIX filename sendmail - e-mail transfer program Stores and forwards mail to other users, machines 11 TCP/IP Applications NFS - Network File System Allows remote disks on another system to appear local Slower, more convenient for accessing common data Has several cousins w/ additional features, complexity AFS - Andrew File System DFS - Distributed File System OSF DCE - Distributed Computing Environment WWW - World Wide Web Client-server protocol with generic client, the browser Provides interconnected Hypertext documents, forms Supports application development via CGI scripts, Java 12 6

The telnet Command Telnet Access The telnet client is a TCP/IP utility that enables terminal access telnet is normally invoked from the command line in the format: $ telnet hostid telnet also supports an interactive mode Upon connection you will be prompted for Userid and Password 13 TCP/IP Applications: rsh, rexec rsh - Remote Shell Permits you to issue a command on another machine and receive the response Sending host, userid must be pre-authorized.rhosts file contains permitted machines, usernames Userid and cmd text traverses network, but not passwd $ rsh rexxdog ls -al rexec - Remote Execution Issue a command on remote host & receive response Userid, password, and cmd text traverses the network $ rexec -l bstark -p pswd rexxdog ls -al Userid and password from.netrc file in home directory machine rexxdog login bstark password pswd $ chmod go-rwx.netrc (Remove others access) 14 7

FTP (File Transfer Protocol) File Transfer Protocol (ftp) ftp allows users to transfer files between systems Any machine (UNIX or otherwise) may make an ftp connection to any other machine if both support the protocol ftp has a command line mode and an interactive or command mode From the command line, ftp operates like telnet: $ ftp rexxdog.protechtraining.com -or- $ ftp 209.161.92.101 15 Socket Programming Overview TCP/IP implementations provide a C language programming API for socket functions Sockets are like file handles: Open a socket, read from the socket Write to the socket, close the socket You can use TCP or UDP protocols, but most applications use TCP, since it is easier Data sent and received on a socket is not translated The standard is to send ASCII characters, so you must provide your own EBCDIC translation on mainframes You must also work out the byte ordering for numbers (big-endian or little-endian) Sockets are full duplex: a program can both read and write to the same socket 16 8

Socket Programming Overview REXX Programming interfaces are provided for: z/os & OS/390 TSO/E REXX via IBM TCP/IP stack Documented in SC31-8788 z/os Communications Server IP Application Programming Interface Guide Uses the SOCKET() function Compatible with VM and VSE Windows, AIX, Linux, OS/2 via RxSock function library Documented in Object REXX for Windows REXX TCP/IP Socket Library Functions (RxSock) Provides 27 REXX functions, all starting w/ Sock () Regina REXX (many platforms) provides an RxSock compatible version matching the IBM Object REXX 17 Basic Socket Send/Receive Functions SockSocket(domain, type, protocol) PC Socket('SOCKET', domain, type, protocol) MVS Creates a new socket and returns its number Typical parms: 'AF_INET','SOCK_STREAM', 'IPPROTO_TCP' SockRecv(socket, buffer, length, flags) PC Socket('Recv', socket, length, flags) MVS Reads data from socket, up to length bytes (may return less) SockSend(socket, datatosend, flags) PC Socket('Send', socket, datatosend, flags) MVS Writes datatosend to socket SockClose(socket) PC Socket('Close', socket) MVS Closes socket (makes it unusable on both sides) 18 9

Resolver, Port number Socket functions deal with IP addresses, not hostnames SockGetHostByName() Converts a hostname to an IP address, by interfacing to the resolver on the local machine Generally, the resolver communicates with one or more DNS servers Use this to accept both IP addresses and/or hostnames Multiple servers on a machine are distinguished by port number Client and server MUST agree on the port number Hard-code the port number in your program, or accept it as a parameter in both client and server 19 20 Basic Socket Connection Functions SockBind(socket, address) PC/UNIX Socket('Bind', socket, address) MVS Used by servers to reserve a port SockAccept(socket, [address] ) PC/UNIX Socket('Accept', socket) MVS Used by servers to wait for a client to make a connection socket must have been previously bound When a connection occurs, a new socket is returned, which is used for further communication with the client (original socket remains open, waiting for new connections) SockConnect(socket, address) PC/UNIX Socket('Connect', socket) MVS Used by clients to connect to a server 10

Basic Socket Connection Functions Client SockSocket() SockConnect() loop... SockSend() SockRecv() Server SockSocket() SockBind() loop... SockAccept() loop... SockRecv() SockSend() SockClose() SockClose() SockClose() 21 Sample TCP/IP Socket Application Echo client and server, written by Thorsten Schaper of IBM Client sends a string to the server Server appends text to the string and sends it back Contains both Mainframe and PC/UNIX implementations Server can handle multiple clients, Host or workstation EBCDIC <-> ASCII translation is handled Available for download at: ftp://service.boulder.ibm.com/ps/products/ad/obj-xx/rxsocket.zip 22 11

Sample TCP/IP Socket Application D:\>rexx serverw.rex -> trying to bind service to: host = 127.0.0.1 port = 5000...listening for clients on socket: 300 -> trying to accept a new client...ok, new client is connected on socket: 308...clientInfo: WindowsNT COMMAND D:\download\rexx\rxsocket\clientw.rex -> got a request from client connected at socket: 308...received: 'TXTHello, this is a test message'...answering: 'server has received your text :'TXTHello, this is a test message' -> got a request from client connected at socket: 308...received: 'CMDshutDownService' -> shutting down all sockets... 308: is down. 300: had problems -> RC = -1 4.) close connection & exit -> Socket REXX-API functions NOT dropped to avoid crashing other REXX programs that are using the Socket API at the moment. good bye D:\>rexx clientw.rex...trying to connect to service at: host = 127.0.0.1 port = 5000 --> established on socket: 300 1.) send 'TXTHello World!' text message 2.) enter text for sending a text message 3.) send 'CMDshutDownService' command message 4.) close connection & exit 2 Hello, this is a test message =====================================...sent text was : 'TXTHello, this is a test message'...server replied : 'server has received your text :'TXTHello, this is a test message'' ===================================== 1.) send 'TXTHello World!' text message 2.) enter text for sending a text message 3.) send 'CMDshutDownService' command message 3 =====================================...sent text was : 'CMDshutDownService' 23 Server Client xsocket() Internal Function Internal REXX function used to map calls to MVS socket() into Windows/Linux/OS/2 Socket API Pasted in via rxcopy edit macro On MVS, it is a strait pass-thru Other platforms, it calls the appropriate socket function, and places the data into MVS format Sets variables: xsrc = 0 (no error), or mnemonic, e.g. EWOULDBLOCK xsrcmsg = '' (no error), or error msg, e.g. Operation would block Application xsocket() rxsock.dll non-mvs socket() MVS 24 12

Practical Applications from the Field Client connection between CA-OPS/MVS (Automated Operations) & BMC Patrol Enterprise Manager (PEM) Client replaced BMC host product but kept PEM Interface enabled MVS REXX code to open alerts on PEM Implemented as an MVS Started Task written in REXX Trouble Ticket interface between MVS and Expert Advisor running on Windows Expert Advisor has a command line interface for integration with HP-OpenView and NetView for AIX Installed Denicomp systems rexec daemon www.denicomp.com - 800-2424-PSL Implemented rxrexec() external function, which implements REXEC protocol but stores encrypted password elsewhere 25 This slide intentionally left blank 26 13