Socket Server
A socket connection can be established to TbredComm by starting TbredComm in ‘socker server’ mode allowing a client application to send and retrieve data to/from the TbredComm emulation window.
Establishing a Connection to TbredComm
Section titled “Establishing a Connection to TbredComm”The following steps describe how to make a socket connection to TbredComm:
-
Start TbredComm with the Socket Server option:
C:\Program Files (x86)\TSI\Bin\Tbredcom.exe –SS <port-number>
-
Connect to a system. Once a telnet/SSH connection has been established, TbredComm will start listening on the specified port number.
-
From a client application, create and connect to TbredComm using the IP address and port number.
TbredComm/Client Application Communication
Section titled “TbredComm/Client Application Communication”After a connection to the TbredComm socket server port has been established, all messages to TbredComm must be in the following format:
| <Message-Header><Message><Message-Trailer> where: | |
|---|---|
| Message-Header | string value 0x01 + “GUI” |
| Message | see the Host/TbredComm Messages |
| Message-Trailer | string value 0x01 + “IUG” |
Responses sent to the host by TbredComm are not enclosed by the message header or trailer.
Host/TbredComm Messages
Section titled “Host/TbredComm Messages”The following list summarizes the actions a client application can make to TbredComm via the socket server connection:
| Host/TBC | TBC/Host | Message Description |
|---|---|---|
| SC** | CS** | Screen Scraping establishment (host/workstation) |
| SC01 | CS01 | Screen Scraping request – Box |
| SC02 | CS02 | Screen Scrapping request – Character |
| SC03 | CS03 | Screen Scrapping request – Field |
| SC04 | CS04 | Screen Scrapping request - Row |
| SC05 | CS05 | Screen Scraping request – Cursor Position |
| SI** | IS** | Socket Input establishment (host/workstation) |
| SI01 | IS01 | Socket Input request |
| SI05 | IS05 | Socket Input – Set Cursor Position request |
Screen Scraping Messages
Section titled “Screen Scraping Messages”The following messages are used to retrieve information from the TbredComm emulation window:
| Pos. | Len. | Description | |||
|---|---|---|---|---|---|
| 1 | 4 | SC** Screen Scraping establishment | |||
| Pos. | Len. | Response Description | |||
| 1 | 4 | CS** Screen Scraping established | |||
| 1 | 4 | CS00 Screen Scraping not established | |||
| 1 | 4 | SC01 Screen Scraping request - Box | |||
| 5 | 3 | Top row number | |||
| 8 | 3 | Left column number | |||
| 11 | 3 | Bottom row number | |||
| 14 | 3 | Right column number | |||
| Pos. | Len. | Response Description | |||
| 1 | 4 | CS01 Screen Scraping response - Box | |||
| 5 | 5 | Length of string starting at position 10 | |||
| 10 | n | Screen data Note: Multiple rows of screen data will be separated | by 0xFF’s. |
- 1
- 4 SC02 Screen Scraping request - Character
- 5
- 3 Column number
- 8
- 3 Row number
- Pos.
- Len. Response Description
- 1
- 4 CS02 Screen Scraping response - Character
- 5
- 1 Character data
- 1
- 4 SC03 Screen Scraping request - Field
- 5
- 3 Starting column number
- 8
- 3 Ending column number
- 11
- 3 Row number
| Pos. | Len. | Response Description |
|---|---|---|
| 1 | 4 | CS03 Screen Scraping response - Field |
| 5 | 5 | Length of string starting at position 10 |
| 10 | n | Field data |
- 1
- 4 SC04 Screen Scraping request - Row
- 5
- 3 Row number
- Pos.
- Len. Response Description
- 1
- 4 CS04 Screen Scraping response - Row
- 5
- 5 Length of string starting at position 10
- 10
- n Row data
- 1
- 4 SC05 Screen Scraping request – Cursor Position
| Pos. | Len. | Response Description |
|---|---|---|
| 1 | 4 | CS05 Screen Scraping response - Cursor Position |
| 5 | 3 | Column number |
| 8 | 3 | Row number |
Socket Input Messages
Section titled “Socket Input Messages”| The Pos. | following Len. | messages Description | are | used insert | data into the TbredComm emulation window. |
|---|---|---|---|---|---|
| 1 | 4 | SI** | Socket | Input | establishment |
| Pos. | Len. | Response Description | |||
| 1 | 4 | IS** | Socket Input established | ||
| 1 | 4 | IS00 | Socket Input not established | ||
| 1 | 4 | SI01 | Socket | Input | request |
| 5 | 1 | Response flag | (Y/N) | ||
| 6 | 5 | Length | of string | starting | at position 11 |
| 11 | n | Input | data | ||
| Pos. | Len. | Response Description | |||
| 1 | 4 | IS01 | Socket Input response | ||
| 5 | 1 | Input | status: |
1 = Successful
0 = Not successful
| Note: An input data string of length 0 will return | a 'not successful' status. | ||||
| 1 | 4 | SI05 | Socket Input – Set Cursor Position request | ||
| 5 | 1 | Response flag (Y/N) | |||
| 6 | 3 | Column number | |||
| 9 | 3 | Row number | |||
| Pos. | Len. | Response Description | |||
| 1 | 4 | IS05 | Socket Input – Set Cursor Position response | ||
| 5 | 1 | Set Cursor Position status: |
1 = Successful
0 = Not successful
Note: An invalid cursor position will return a ‘not successful’ status.
Connection Example
Section titled “Connection Example”The following example uses Thoroughbred Basic to connect to a TbredComm socket server running on 192.168.1.100 listening on port 6006. Then, using the screen scraping and socket input messages makes the Basic running in TbredComm go to console mode from the OPENworkshop menu then gets and displays the version of Basic.
00010 REM "TEST TBREDCOMM SOCKET SERVER"00100 SETERR 08000; SETESC 0900000500 GUIH$=$01$+"GUI", GUIT$=$01$+"IUG", MSK$="000"; IPA$="192.168.1.100", SSP=600601000 OSS$=IPA$+":"+STR(SSP); SSC=UNT; OPEN (SSC,OPT="SOCKET") OSS$; GOSUB SEND_SCXX; GOSUB SEND_SIXX; DATA$="C"+$0A$; GOSUB SEND_SI01Y; GOSUB SEND_SC05; SROW=ROW; DATA$="DUMP VERSION"+$0A$; GOSUB SEND_SI01Y; GOSUB SEND_SC05; EROW=ROW; TOP=SROW+1, LEFT=0, BOTTOM=EROW-2, RIGHT=78; GOSUB SEND_SC01; FOR I=0 TO NEA("SCDATA$",1); PRINT SCDATA$[I]; NEXT I; CLOSE (SSC)06900 GOTO 0900007000 SEND_SCXX: GMSG$=GUIH$+"SC**"+GUIT$; WRITE (SSC) GMSG$; READ (SSC,TIM=30) R$; RETURN07010 SEND_SC01: GMSG$=GUIH$+"SC01"+STR(TOP:MSK$)+STR(LEFT:MSK$)+STR( BOTTOM:MSK$)+STR(RIGHT:MSK$)+GUIT$; WRITE (SSC) GMSG$; READ (SSC,TIM=30) R$; DIM SCDATA$[BOTTOM-TOP]; SCDATA$=R$(10), I=0; WHILE LEN(SCDATA$); P=POS($FF$=SCDATA$); IF P>0 SCDATA$[I]=SCDATA$(1,P-1), SCDATA$=SCDATA$(P+1) ELSE SCDATA$[I]=SCDATA$, SCDATA$="" FI; I=I+1; WEND; RETURN07020 SEND_SC05: GMSG$=GUIH$+"SC05"+GUIT$; WRITE (SSC) GMSG$; READ (SSC,TIM=30) R$; COL=NUM(R$(5,3)), ROW=NUM(R$(8,3)); RETURN07050 SEND_SIXX: GMSG$=GUIH$+"SI**"+GUIT$; WRITE (SSC) GMSG$; READ (SSC,TIM=30) R$; RETURN07060 SEND_SI01Y: GMSG$=GUIH$+"SI01Y"+STR(LEN(DATA$):"00000")+DATA$+GUIT$; WRITE (SSC) GMSG$; READ (SSC,TIM=30) R$; RETURN07070 SEND_SI01N: GMSG$=GUIH$+"SI01N"+STR(LEN(DATA$):"00000")+DATA$+GUIT$; WRITE (SSC) GMSG$; RETURN08000 PRINT "**ERROR: ",STR(ERR)," (",ERM(ERR),")"; INPUT *09000 CLOSE (0); ENDFrom the TbredComm Reference, version 8.9.1. Open this page in the PDF