[0001]
[0002]
[0003]
[0004]
[0005]
[0006]
[0007]
[0008]
[0009]
[0010]
[0011]
[0012]
[0013]
[0014]
[0015]
[0016]
[0017]
[0018]
[0019]
[0020]
[0021]
[0022]
[0023]
[0024]
[0025]
[0026]
[0027]
[0028]
[0029]
[0030]
[0031]
[0032]
[0033]
[0034]
[0035]
[0036]
[0037]
[0038]
[0039]
[0040]
[0041]
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048]
[0049]
[0050]
[0051]
[0052]
[0053]
[0054]
[0055]
[0056]
[0057]
[0058]
[0059]
[0060]
[0061]
$! RAW_SOCKET.COM
$! Not intended as anything other than illustrative.
$! 30-NOV-2016  MGD  initial
$!
$ wrwso = "write RawSocketOutput"
$ wrsys = "write sys$output"
$ crlf[0,16] = %x0a0d
$ UsageCount = 0
$ FirstUsed = f$time()
$ open /read CgiPlusIn CGIPLUSIN
$!
$ RequestLoop:
$!
$!   (block waiting for request, this initial read is always discardable)
$    read CgiPlusIn /end=EndRequestLoop Line
$    UsageCount = UsageCount + 1
$!
$    WWW_WEBSOCKET_INPUT = ""
$    WWW_WEBSOCKET_OUTPUT = ""
$!
$!   (read the CGIplus variable stream looking for the WebSocket variables)
$    CgiVarLoop:
$       read CgiPlusIn /end=EndCgiVarLoop Line
$       if Line .eqs. "" then goto EndCgiVarLoop
$       if f$extract(0,20,Line) .eqs. "WWW_WEBSOCKET_INPUT=" -
           then WWW_WEBSOCKET_INPUT = f$extract(21,999,Line)
$       if f$extract(0,21,Line) .eqs. "WWW_WEBSOCKET_OUTPUT=" -
           then WWW_WEBSOCKET_OUTPUT = f$extract(22,999,Line)
$       goto CgiVarLoop
$    EndCgiVarLoop:
$!
$    if WWW_WEBSOCKET_INPUT .eqs. "" .or. -
        WWW_WEBSOCKET_OUTPUT .eqs. ""
$    then
$       wrsys "status: 500" + crlf
$       wrsys crlf
$       exit
$    endif
$!
$!   (inform the server the script has been successfully activated)
$    wrsys "HTTP/1.1 101 Switching Protocols" + crlf
$    wrsys crlf
$!
$    open /read RawSocketInput 'WWW_WEBSOCKET_INPUT'
$    open /write RawSocketOutput 'WWW_WEBSOCKET_OUTPUT'
$!
$    wrwso f$fao("!80*>") + crlf
$    wrwso f$environment("procedure") + crlf
$    wrwso "Number of times used: ''UsageCount'" + crlf
$    wrwso "First used: ''FirstUsed'" + crlf
$    wrwso "Now: ''f$time()'" + crlf
$    wrwso f$fao("!80*<") + crlf
$!
$    wrsys f$trnlnm("CGIPLUSEOF") + crlf
$!
$    close RawSocketInput
$    close RawSocketOutput
$!
$    goto RequestLoop
$!
$ EndRequestLoop: