Introduction

Language Structure

IB Statements

File System

Comet 32 Runtime

Index

STS function

(Winsock gateway)

 

 

Syntax:           STS(lun)

 

Description:    The STS function returns the operating status of the Winsock gateway device that is open on the specified logical unit number (lun).

 

Remarks:       Executing the STS function results in 62 bytes of string information describing the operating condition of the Winsock gateway. Calling the STS function frequently is strongly discouraged as a 5-second PAUSE is taken for each call to the STS function in which the Data Status, Connection Status and Last Winsock Error remain unchanged between calls. If during the PAUSE, data become available, or a connection is established from a LISTEN, the STS function immediately returns control back to the calling application.

 

Return values :

 

                        The string returned represents a data structure with the following format:

                       

Position

Size

Description

1

1

Connection Status:

0 = Not Connected.

1 = Connected.

2 = Listening (but not connected)

2

1

Data Status:

0 = No Data Available, INPUT will block.

1 = Data Ready, INPUT returns waiting data.

3

2

Reserved

5

5

Last Winsock Error; length/precision is 5.0

10

21

IP address and port of peer, when connected.

Example: "192.168.1.1:80"

31

21

IP address and port assigned to LISTEN.

Example: "127.0.0.1:25"
This is the IP address of the local machine.

52

5

Current TIMEOUT in ticks; length/precision is 5.0

57

1

Current WEOL state:

0 = Print data is sent as is.  No CRLFs are appended.

1 = CRLF are appended to print data.

58

5

Last I/O count; length/precision is 5.0 (added in .367 release)

                               

Error Codes:  None

 

Example:        LENGTH 63 & LOCAL Status$

            LENGTH 80 & LOCAL Result$

            LENGTH 21 & LOCAL PeerAddr$

 

            Result$ = CONTROL(1, "LISTEN 5555")

            IF SUB(Result$,1,1) NE "+" GOTO ErrorHandler

           

            PRINT "Waiting for connection..."

            Status$ = STS(1)

            DO WHILE SUB(Status$,1,1) NE "1"

                GOSUB Stuff.To.Do.When.Idle

                Status$ = STS(1)  ! may get paused

            LOOP

            PeerAddr$ = SUB(Status$,10,21)

            print "Connected with "; PeerAddr$