Winsock Gateway Subroutine
Copy this code and paste it into your source program
SET WSGateway = 20 ! set LUN for gateway
GOSUB Find.Gateway
IF GateName$ EQ "" GOTO Abort
.
.
.
! This subroutine searches all of the gateways (G00 through G99)
! and looks for one that is configured as a Type 3 gateway.
! If found, the gateway is opened. If an exception happens
! on the open, this routine keeps looking for another Type
! 3 gateway. If no available Type 3 gateway is found, GateName$
! is set to null.
Find.Gateway:
FOR I = 100 TO 199
GateName$ = "G" + SUB(STRIP(STR(I)),2,2)
IF SUB(DSTAT(GateName$,EXCP=Next.Gateway),4,1) EQ "@03@" THEN
GOTO Gateway.Found
ENDIF
Next.Gateway:
NEXT I
GateName$ = ""
RETURN
Gateway.Found:
CLOSE (WSGateway)
OPEN (WSGateway) GateName$, EXCP=Next.Gateway
RETURN