SmartSockets Java Tutorial
142 Pages
English

SmartSockets Java Tutorial

Downloading requires you to have access to the YouScribe library
Learn all about the services we offer

Description

SmartSockets
Java Tutorial
Version 5.0
TALARIAN CORPORATE HEADQUARTERS
333 Distel Circle
Los Altos, CA 94022
(800) 883-8050
FAX: (800) 883-8057
E-MAIL: info@talarian.com
URL: http://www.talarian.com ª
ª
In the United States, RTworks, SmartSockets, and Talarian are registered trademarks of Talarian Corporation. RTie, RTdaq,
RThci, RTdraw, RTsdb, RTlm, RTserver, RTmon, RTgen, RTgredit, RTarchive, and RTplayback are trademarks of Talarian
Corporation. All other products are trademarks, services, or registered trademarks of their respective vendors.
Talarian Corporation reserves the right to make changes in specifications and other information contained in
this publication without prior notice. The reader should in all cases consult Talarian Corporation to
determine whether any such changes have been made.
COPYRIGHT 1991-1998 TALARIAN CORPORATION. PORTIONS COPYRIGHT 1998 DATAVIEWS
CORPORATION. ALL RIGHTS RESERVED. UNPUBLISHED – RIGHTS RESERVED UNDER THE
COPYRIGHT LAWS OF THE UNITED STATES. USE OF A COPYRIGHT NOTICE IS PRECAUTIONARY
ONLY AND DOES NOT IMPLY PUBLICATION OR DISCLOSURE.
THIS DOCUMENT CONTAINS PROPRIETARY AND CONFIDENTIAL INFORMATION OF TALARIAN
CORPORATION AND/OR ITS SUPPLIERS. USE, DISCLOSURE, OR REPRODUCTION IS PROHIBITED
WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF TALARIAN CORPORATION.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c) (1)
(ii) of the Rights in Technical ...

Subjects

Informations

Published by
Reads 564
Language English
SmartSockets Java Tutorial Version 5.0 TALARIAN CORPORATE HEADQUARTERS 333 Distel Circle Los Altos, CA 94022 (800) 883-8050 FAX: (800) 883-8057 E-MAIL: info@talarian.com URL: http://www.talarian.com ª ª In the United States, RTworks, SmartSockets, and Talarian are registered trademarks of Talarian Corporation. RTie, RTdaq, RThci, RTdraw, RTsdb, RTlm, RTserver, RTmon, RTgen, RTgredit, RTarchive, and RTplayback are trademarks of Talarian Corporation. All other products are trademarks, services, or registered trademarks of their respective vendors. Talarian Corporation reserves the right to make changes in specifications and other information contained in this publication without prior notice. The reader should in all cases consult Talarian Corporation to determine whether any such changes have been made. COPYRIGHT 1991-1998 TALARIAN CORPORATION. PORTIONS COPYRIGHT 1998 DATAVIEWS CORPORATION. ALL RIGHTS RESERVED. UNPUBLISHED – RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF THE UNITED STATES. USE OF A COPYRIGHT NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION OR DISCLOSURE. THIS DOCUMENT CONTAINS PROPRIETARY AND CONFIDENTIAL INFORMATION OF TALARIAN CORPORATION AND/OR ITS SUPPLIERS. USE, DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF TALARIAN CORPORATION. RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c) (1) (ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013. Talarian Corporation 333 Distel Circle, Los Altos, CA 94022 Table of Contents Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii List of Figures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii CHAPTER 1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 Intended Audience. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 How This Tutorial is Organized . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 Conventions Used in This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 Prompts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 The Mouse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 The Keyboard. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 Terminal Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 Typefaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 Numeric Range Delimiters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 Things to Remember . . . . . . . . . 1-4 Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 Case Sensitivity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5 Reporting Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5 CHAPTER 2 Introducing SmartSockets . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 What Makes up SmartSockets? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 SmartSockets Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 Platform Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 Source Code Availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Programming Language Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Major Components of SmartSockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Message Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 Working with Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 Message Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 Connections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 Connection Composition . . . . . . . . 2-7 Advantages of Connections Over Sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 SmartSockets Java Tutorial iii Table of Contents RTserver and RTclient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-8 RTserver and RTclient Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-8 Projects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-9 Subjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-9 RTserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10 RTclient. . . . . . . . . . . . . 2-11 Connections Versus RTserver and RTclient . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11 RTmon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12 CHAPTER 3 Getting Started with the SmartSockets Java Library . . . . . . . . .3-1 Configuring Your System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-1 Using the SmartSockets Java Class Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-1 Java Class Library Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-2 LESSON 1 Your First SmartSockets Java Program. . . . . . . . . . . . . . . . . . L1-1 A "Hello World!" Program . . . . . . . L1-2 Compiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L1-3 A Program to Read a Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L1-4 Running the Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L1-5 What’s Going On. . . . . . . . . . L1-6 A Word About Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L1-6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L1-7 LESSON 2 Communicating Using a Publish-Subscribe Model . . . . . . . . L2-1 What is an RTserver? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-2 Running an RTserver. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-4 Starting an RTserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-4 Starting an RTserver Manually . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-4 Auto-Starting an RTserver. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-5 Stopping an RTserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-5 RTserver Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-6 What is a SmartSockets Project?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-7 What are Subjects? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-10 Understanding Hierarchical Subject Namespace . . . . . . . . . . . . . . . . . . . . . . . . L2-11 Specifying Wildcards in Subjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Demonstrating Message Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-11 Demonstrating Publish-Subscribe Services . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-12 Using Load Balancing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-14 Connecting to an RTserver on Another Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-16 Disconnecting from an RTserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-17 LESSON 3 Working with Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . L3-1 What is in a Message? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L3-1 What is Automatic Data Translation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L3-3 What are Message Types? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L3-4 Working With Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L3-9 Summary . . . . . . . . . . L3-13 iv SmartSockets Version 5.0 Table of Contents LESSON 4 Working with Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-1 Introducing Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-1 Creating Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-3 Manipulating Callback Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-3 Destroying Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-4 Working With Callbacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-4 Process Callbacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-4 Default Process Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-5 Read Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-5 Write Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-5 Server Create Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-5 Server Destroy Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-6 Error Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-6 Using Callbacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-6 Writing a Process Callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-6 Writing a Default Process Callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-9 Writing a Subject Callback. . . . . . . L4-15 Specifying a Callback Based on Subject and Message Type . . . . . . . . . . . . . . . . L4-19 Using the TipSrv.mainLoop Convenience Method. . . . . . . . . . . . . . . . . . . . . . . L4-21 Using Server Create and Destroy Callbacks. . . . . . . . . . . . . . . . . . . . . . . . . . . L4-22 Creating Your Own Message Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-26 Sample Programs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-27 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-33 LESSON 5 Using SmartSockets Options . . . . . . . . . . . . . . . . . . . . . . . . L5-1 Option (Property) Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L5-1 Utility Methods for Handling Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L5-2 Setting Simple RTclient Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L5-2 Working with Enumerated Options . . . . L5-3 Loading RTclient Options from a File or URL . . . . . . . . . . . . . . . . . . . . . . . . . . L5-4 Making Custom Options Read-Only. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L5-8 Summary . . . . . . . . . . . L5-8 LESSON 6 SmartSockets and Java Applets . . . . . . . . . . . . . . . . . . . . . . L6-1 Applets and the Security Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L6-1 Network Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L6-2 Local Machine Lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L6-2 Local Filesystem Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L6-2 Applet Lifecycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L6-2 Using Messaging Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L6-2 A Word on JVM Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L6-4 Example Applet: ChatApplet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L6-4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L6-13 CHAPTER 4 RTclient Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1 Option (Property) Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1 Loading RTclient Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1 Setting RTclient Options . . . . . . . . . 4-2 ss.default_msg_priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3 ss.default_subject_prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3 ss.enable_control_msgs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3 SmartSockets Java Tutorial v Table of Contents ss.project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-4 ss.server_auto_connect. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-4 ss.server_auto_flush_size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-4 ss.server_delivery_timeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-4 ss.server_disconnect_mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-5 ss.server_keep_alive_timeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5 ss.server_msg_send. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-6 ss.server_names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-6 ss.server_read_timeout. . . . . . . . . .4-6 ss.server_start_delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-6 ss.server_write_timeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-6 ss.socket_connect_timeout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-7 ss.subjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-7 ss.unique_subject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-7 ss.user_name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-8 vi SmartSockets Version 5.0 List of Figures Figure 2.1 RTserver and RTclient Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10 Figure 2.2 RTmon Graphical Development Interface Main Window . . . . . . . . . . . . . . 2-13 Figure L2.1 Process Connectivity With RTserver Cloud . . . . . . . . . . . . . . . . . . . . . . L2-3 Figure L2.2 RTserver Message Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-12 Figure L2.3 Messages Delivered With and Without Load Balancing L2-15 Figure L3.1 Composition of a Typical Message . . . . . . . . . . . . . . . . . . . . . . . . . . . L3-2 Figure L3.2 Composition of a NUMERIC_DATA Message. . . . . . . . . . . . . . . . . . . . . L3-4 Figure L6.1 AppletViewer display of ChatApplet (login phase) . . . . . . . . . . . . . . . . . L6-12 Figure L6.2iewer display of ChatApplet (chat phase) . . . . . . . . . . . . . . . . . L6-12 Figure L6.3 Browser display of ChatApplet . . . . . . . . . . . . . . . . . . . . . . . . . . . . L6-13 SmartSockets Java Tutorial vii List of Figures viii SmartSockets Version 5.0 List of Tables Table L2.1 RTserver Stop Command Arguments. . . . . . . . . . . . . . . . . . . . . . . . . . L2-6 Table L2.2 Load Balancing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L2-15 Table L3.1 Message Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L3-2 Table L3.2 Standard Message Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L3-5 Table L4.1 Callback Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-2 Table L4.2 TipcCb Utility Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-4 Table L4.3 Field Type Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L4-27 Table L5.1 Options-Related Tut Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L5-2 Table 4.1 Java RTclient Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 SmartSockets Java User’s Guide ix x SmartSockets Version 5.0