GUI Innovations for Innovative Solutions

Code Samples

There are 2 code samples on the page. Code covering the CeSockets dll can be found here.

The first sample shows how to connect Visual Basic to the HPe3000, and hold a simple conversation over TCP/IP using Cobol on the HPe3000.

The second sample is for the Pocket PC, and is a simple terminal emulator showing how to handle binary data with the Winsock control.

 

Visual Basic to HPe3000 Sample

Due to various requests noted on the MPE news group, I have written a sample Client/Server application to show the basic mechanics of TCP/IP protocol and the HPe3000. The zip file below contains a sample TCP/IP client, written in Visual Basic, and a sample TCP/IP server for the HPe3000 server written in Cobol. The Cobol program is based on articles written by Joe Sagan in Interact magazine July and August 1993. Unzip the files to your PC, and then copy the file SKSAMPCB.TXT to your HPe3000. Compile the file to an NMOBJ, and the link the file, using SOCKETXL, e.g.

COB85XL SKSAMPCB,SKSAMPOB,$NULL

LINK SKSAMPOB,SOCKSAMP;XL="SOCKETXL.NET.SYS"

SOCKSAMP

The server will display a message "Waiting for client on port 9876".

Run Visual Basic, and open the project sockets.vbp. Run the project, enter the IP Address or name of your server in the box labelled 'Host Name', then click on Connect. The client will connect to your server process, and display a message to this effect. Enter a string of data in the box labelled 'Data to send', and then click on Send. This will send the data to the server, and should echo back a response. The server will display the first 20 characters of the data sent.

Since I released this code, I discovered that the Winsock control used in the VB sample has a memory leak. Every time you transmit and receive a message, the control does not release the bytes used. There are a couple of alternatives to the Microsoft control. A free socket control is available from www.catalyst.com,or an alternative can be found at www.mabry.com.This bug does not affect GUI3000, as GUI3000 uses 'native' calls to the winsock dll.

This is only a very simple example of the protocol, and should be used as a learning tool only. If you have any questions about this sample, please e-mail me on pete@gui-innovations.com .

 

eVB Winsock Terminal Example

As anyone who has tried programming in eVB with the Winsock control will know, this is not an easy task, as the Winsock control has some nasty bugs in it. The worst of this, is its inability to retrieve binary data. There is a way round this, but it is not the most efficient method in the world.

To illustrate the method I used, I have written a simple telnet terminal program. All you need to do is enter the IP address of your server, and connect. Any ‘binary’ data is dealt with in the ‘Translate_Buffer’ subroutine.

The most complex part of the code is the ‘Showdata’ sub, which just ensures the text box doesn’t exceed the maximum size of a text box in eVB.

This is only a very simple example of the protocol, and should be used as a learning tool only. If you have any questions about this sample, please e-mail me on pete@gui-innovations.com .

 

Download the Code