[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]
[0062]
[0063]
[0064]
[0065]
[0066]
[0067]
[0068]
[0069]
[0070]
[0071]
[0072]
[0073]
[0074]
[0075]
[0076]
[0077]
[0078]
[0079]
[0080]
[0081]
[0082]
[0083]
[0084]
[0085]
[0086]
[0087]
[0088]
[0089]
[0090]
[0091]
[0092]
[0093]
[0094]
[0095]
[0096]
[0097]
[0098]
[0099]
[0100]
[0101]
[0102]
[0103]
[0104]
[0105]
[0106]
[0107]
[0108]
[0109]
[0110]
[0111]
[0112]
[0113]
[0114]
[0115]
[0116]
[0117]
[0118]
[0119]
[0120]
[0121]
[0122]
[0123]
[0124]
[0125]
[0126]
[0127]
[0128]
[0129]
[0130]
[0131]
[0132]
[0133]
[0134]
[0135]
[0136]
[0137]
[0138]
[0139]
[0140]
[0141]
[0142]
[0143]
[0144]
[0145]
[0146]
[0147]
[0148]
[0149]
[0150]
[0151]
[0152]
[0153]
[0154]
[0155]
[0156]
[0157]
[0158]
[0159]
[0160]
[0161]
[0162]
[0163]
[0164]
[0165]
[0166]
[0167]
[0168]
[0169]
[0170]
[0171]
[0172]
[0173]
[0174]
[0175]
[0176]
[0177]
[0178]
[0179]
[0180]
[0181]
[0182]
[0183]
[0184]
[0185]
[0186]
[0187]
[0188]
[0189]
[0190]
[0191]
[0192]
[0193]
[0194]
[0195]
[0196]
[0197]
[0198]
[0199]
[0200]
[0201]
[0202]
[0203]
[0204]
[0205]
[0206]
[0207]
[0208]
[0209]
[0210]
[0211]
[0212]
[0213]
[0214]
[0215]
[0216]
[0217]
[0218]
[0219]
[0220]
[0221]
[0222]
[0223]
[0224]
[0225]
[0226]
[0227]
[0228]
[0229]
[0230]
[0231]
[0232]
[0233]
[0234]
[0235]
[0236]
[0237]
[0238]
[0239]
[0240]
[0241]
[0242]
[0243]
[0244]
[0245]
[0246]
[0247]
[0248]
[0249]
[0250]
[0251]
[0252]
[0253]
[0254]
[0255]
[0256]
[0257]
[0258]
[0259]
[0260]
[0261]
[0262]
[0263]
[0264]
[0265]
[0266]
[0267]
[0268]
[0269]
[0270]
[0271]
[0272]
[0273]
[0274]
[0275]
[0276]
[0277]
[0278]
[0279]
[0280]
[0281]
[0282]
[0283]
[0284]
[0285]
[0286]
[0287]
[0288]
[0289]
[0290]
[0291]
[0292]
[0293]
[0294]
[0295]
[0296]
[0297]
[0298]
[0299]
[0300]
[0301]
[0302]
[0303]
[0304]
[0305]
[0306]
[0307]
[0308]
[0309]
[0310]
[0311]
[0312]
[0313]
[0314]
[0315]
[0316]
[0317]
[0318]
[0319]
[0320]
[0321]
[0322]
[0323]
[0324]
[0325]
[0326]
[0327]
[0328]
[0329]
[0330]
[0331]
[0332]
[0333]
[0334]
[0335]
[0336]
[0337]
[0338]
[0339]
[0340]
[0341]
[0342]
[0343]
[0344]
[0345]
[0346]
[0347]
[0348]
[0349]
[0350]
[0351]
[0352]
[0353]
[0354]
[0355]
[0356]
[0357]
[0358]
[0359]
[0360]
[0361]
[0362]
[0363]
[0364]
[0365]
[0366]
[0367]
[0368]
[0369]
[0370]
[0371]
[0372]
[0373]
[0374]
[0375]
[0376]
[0377]
[0378]
[0379]
[0380]
[0381]
[0382]
[0383]
[0384]
[0385]
[0386]
[0387]
[0388]
[0389]
[0390]
[0391]
[0392]
[0393]
[0394]
[0395]
[0396]
[0397]
[0398]
[0399]
[0400]
[0401]
[0402]
[0403]
[0404]
[0405]
[0406]
[0407]
[0408]
[0409]
[0410]
[0411]
[0412]
[0413]
[0414]
[0415]
[0416]
[0417]
[0418]
[0419]
[0420]
[0421]
[0422]
[0423]
[0424]
[0425]
[0426]
[0427]
[0428]
[0429]
[0430]
[0431]
[0432]
[0433]
[0434]
[0435]
[0436]
[0437]
[0438]
[0439]
[0440]
[0441]
[0442]
[0443]
[0444]
[0445]
[0446]
[0447]
[0448]
[0449]
[0450]
[0451]
[0452]
[0453]
[0454]
[0455]
[0456]
[0457]
[0458]
[0459]
[0460]
[0461]
[0462]
[0463]
[0464]
[0465]
[0466]
[0467]
[0468]
[0469]
[0470]
[0471]
[0472]
[0473]
[0474]
[0475]
[0476]
[0477]
[0478]
[0479]
[0480]
[0481]
[0482]
[0483]
[0484]
[0485]
[0486]
[0487]
[0488]
[0489]
[0490]
[0491]
[0492]
[0493]
[0494]
[0495]
[0496]
[0497]
[0498]
[0499]
[0500]
[0501]
[0502]
[0503]
[0504]
[0505]
[0506]
[0507]
[0508]
[0509]
[0510]
[0511]
[0512]
[0513]
[0514]
[0515]
[0516]
[0517]
[0518]
[0519]
[0520]
[0521]
[0522]
[0523]
[0524]
[0525]
[0526]
[0527]
[0528]
[0529]
[0530]
[0531]
[0532]
[0533]
[0534]
[0535]
[0536]
[0537]
[0538]
[0539]
[0540]
[0541]
[0542]
[0543]
[0544]
[0545]
[0546]
[0547]
[0548]
[0549]
[0550]
[0551]
[0552]
[0553]
[0554]
[0555]
[0556]
[0557]
[0558]
[0559]
[0560]
[0561]
[0562]
[0563]
[0564]
[0565]
[0566]
[0567]
[0568]
[0569]
[0570]
[0571]
[0572]
[0573]
[0574]
[0575]
[0576]
[0577]
[0578]
[0579]
[0580]
[0581]
[0582]
[0583]
[0584]
[0585]
[0586]
[0587]
[0588]
[0589]
[0590]
[0591]
[0592]
[0593]
[0594]
[0595]
[0596]
[0597]
[0598]
[0599]
[0600]
[0601]
[0602]
[0603]
[0604]
[0605]
[0606]
[0607]
[0608]
[0609]
[0610]
[0611]
[0612]
[0613]
[0614]
[0615]
[0616]
[0617]
[0618]
[0619]
[0620]
[0621]
[0622]
[0623]
[0624]
[0625]
[0626]
[0627]
[0628]
[0629]
[0630]
[0631]
[0632]
[0633]
[0634]
[0635]
[0636]
[0637]
[0638]
[0639]
[0640]
[0641]
[0642]
[0643]
[0644]
[0645]
[0646]
[0647]
[0648]
[0649]
[0650]
[0651]
[0652]
[0653]
[0654]
[0655]
[0656]
[0657]
[0658]
[0659]
[0660]
[0661]
[0662]
[0663]
[0664]
[0665]
[0666]
[0667]
[0668]
[0669]
[0670]
[0671]
[0672]
[0673]
[0674]
[0675]
[0676]
[0677]
[0678]
[0679]
[0680]
[0681]
[0682]
[0683]
[0684]
[0685]
[0686]
[0687]
[0688]
[0689]
[0690]
[0691]
[0692]
[0693]
[0694]
[0695]
[0696]
[0697]
[0698]
[0699]
[0700]
[0701]
[0702]
[0703]
[0704]
[0705]
[0706]
[0707]
[0708]
[0709]
[0710]
[0711]
[0712]
[0713]
[0714]
[0715]
[0716]
[0717]
[0718]
[0719]
[0720]
[0721]
[0722]
[0723]
[0724]
[0725]
[0726]
[0727]
[0728]
[0729]
[0730]
[0731]
[0732]
[0733]
[0734]
[0735]
[0736]
[0737]
[0738]
[0739]
[0740]
[0741]
[0742]
[0743]
[0744]
[0745]
[0746]
[0747]
[0748]
[0749]
[0750]
[0751]
[0752]
[0753]
[0754]
[0755]
[0756]
[0757]
[0758]
[0759]
[0760]
[0761]
[0762]
[0763]
[0764]
[0765]
[0766]
[0767]
[0768]
[0769]
[0770]
[0771]
[0772]
[0773]
[0774]
[0775]
[0776]
[0777]
[0778]
[0779]
[0780]
[0781]
[0782]
[0783]
[0784]
[0785]
[0786]
[0787]
[0788]
[0789]
[0790]
[0791]
[0792]
[0793]
[0794]
[0795]
[0796]
[0797]
[0798]
[0799]
[0800]
[0801]
[0802]
[0803]
[0804]
[0805]
[0806]
[0807]
[0808]
[0809]
[0810]
[0811]
[0812]
[0813]
[0814]
[0815]
[0816]
[0817]
[0818]
[0819]
[0820]
[0821]
[0822]
[0823]
[0824]
[0825]
[0826]
[0827]
[0828]
[0829]
[0830]
[0831]
[0832]
[0833]
[0834]
[0835]
[0836]
[0837]
[0838]
[0839]
[0840]
[0841]
[0842]
[0843]
[0844]
[0845]
[0846]
[0847]
[0848]
[0849]
[0850]
[0851]
[0852]
[0853]
[0854]
[0855]
[0856]
[0857]
[0858]
[0859]
[0860]
[0861]
[0862]
[0863]
[0864]
[0865]
[0866]
[0867]
[0868]
[0869]
[0870]
[0871]
[0872]
[0873]
[0874]
[0875]
[0876]
[0877]
[0878]
[0879]
[0880]
[0881]
[0882]
[0883]
[0884]
[0885]
[0886]
[0887]
[0888]
[0889]
[0890]
[0891]
[0892]
[0893]
[0894]
[0895]
[0896]
[0897]
[0898]
[0899]
[0900]
[0901]
[0902]
[0903]
[0904]
[0905]
[0906]
[0907]
[0908]
[0909]
[0910]
[0911]
[0912]
[0913]
[0914]
[0915]
[0916]
[0917]
[0918]
[0919]
[0920]
[0921]
[0922]
[0923]
[0924]
[0925]
[0926]
[0927]
[0928]
[0929]
[0930]
[0931]
<!DOCTYPE html>
<!-- WASDOC AXP-2.0.0 (CGILIB AXP-1.9.9) -->
<!-- wasDOC Copyright (C) 2019,2020 Mark G.Daniel - Apache-2.0 licenced -->
<!--  3-NOV-2021 02:57 -->
<noscript>NOTE: SOME FUNCTIONALITY EMPLOYS JAVASCRIPT</noscript>
<div id="erreport1" style="display:none;"></div>
<script>
function errorReport(string) {
   for (var cnt = 1; cnt <= 2; cnt++) {
      var err = document.getElementById('erreport'+cnt);
      err.style.display = 'block';
      err.innerHTML += string;
   }
}
</script>
<style type="text/css">
html { font-family: arial, verdana, sans-serif; font-size:12pt; margin:1em; }
h1 { font-size:124%; font-style:bold;
     margin-top:1em; margin-bottom:0.5em; }
h2 { font-size:120%; font-style:bold;
     margin-top:1.1em; margin-bottom:0.4em; }
h3 { font-size:116%; font-style:bold;
     margin-top:1.0em; margin-bottom:0.3em; }
h4 { font-size:112%; font-style:bold;
     margin-top:1.1em; margin-bottom:0.3em; }
h5 { font-size:112%; font-style:bold; 
     margin-top:1.1em; margin-bottom:0.3em; }
h6 { font-size:112%; font-style:bold; padding:0; margin:0; }

h1 .text { text-decoration:underline; }
h1 .numb { padding-right:0.8em; }
h1 .numb:empty { display:none; padding-right:0; }
h2 .numb { padding-right:0.8em; }
h2 .numb:empty { display:none; padding-right:0; }
h3 .numb { padding-right:0.8em; }
h3 .numb:empty { display:none; padding-right:0; }
h4 .numb { padding-right:0.8em; }
h4 .numb:empty { display:none; padding-right:0; }
h5 .numb { display:none; padding-right:0; }
h6 .numb { display:none; padding-right:0; }

kbd { font-family:monospace; }

noscript { font-size:1.2em; }

p { line-height:1.1em; margin-top:1em; margin-bottom:1em; }

.chunk { font-size:130%; text-decoration:underline; }
.head {}
.high {}
.bold { font-weight:bold; }
.center { text-align:center; }
.italic { font-style:italic; }
.left { text-align:left; }
.nowrap { white-space:nowrap; }
.prewrap { white-space:pre; }
.right { text-align:right; }
.strike { text-decoration:line-through; }
.under { text-decoration:underline; }

.backlight { background-color:#f2f2f2; }
.display0 { display:none; }

img { max-width:100%; }
.imglink { }

.link { }
.blank { }

.list { margin-bottom:1em; }
.list li { margin-top:0.5em; }
.list0 li { margin-top:0; }
.item {}

.tabl { border-collapse:collapse; text-align:left; margin:0.4em 2em 0.5em 2em; }
.tabu { border-collapse:collapse; text-align:right; margin:0.4em 2em 0.5em 2em; }

.tabr { vertical-align:top; }
.tabh { padding:0.2em 0 0 2em; margin:0; }
.tabd { padding:0.1em 0 0 2em; margin:0; }
.tabh:first-of-type, td:first-of-type { padding-left:0; }

.tabu .tabh,
.tabu .tabd { border:1px solid gray; padding:0.2em 0.3em 0.2em 0.3em; }
.tab0 { border:none; visibility:hidden; max-width:1em; 
        white-space:nowrap; overflow:hidden; }

.tabauto { margin-left:auto; margin-right:auto; }

.tabr:empty { height:0.2em; }
.tabu .tabh:empty, .tabu .tabd:empty { border:none; visibility:hidden; }

.error { font-size:110%; color:black; background-color:yellow;
         font-family:sans-serif; font-weight:bold; font-style:normal;
         width:95%; border:solid 1px gray; padding:0.5em 1em 0.5em 1em; }
.error::before { content:'\026a0\00a0'; }
.image { }
.page { width:98%; border:1px dashed gray; margin:1.5em 0 1.8em 0; }
.epage { width:98%; border:1px dashed black; margin:1.5em 0 1.8em 0; }
.monosp { font-family:monospace; }
.ppage { display:none; }
.simple { list-style-type:none; }
.valtop { vertical-align:top; }
.valmid { vertical-align:middle; }
.valbot { vertical-align:bottom; }

.code { border-style:solid; border-width:0 0 0 1px; padding-left:1em;
        font-family:monospace; white-space:pre; }
.block { }
.blockof { margin:0.4em 2em 0.5em 2em; }
.example { border-style:dashed; border-width:0 0 0 1px; padding-left:1em;
           margin-top:0.5em; margin-bottom:0.5em; white-space:pre; }
.indent { margin-left:2em; margin-right:2em; }
.noindent { margin-left:0; margin-right:0; }
.inblock { display:inline-block; }
.mono { white-space:pre; font-family:monospace; }
.note { margin:0.4em 2em 0.5em 2em; page-break-inside:avoid; }
.note h5 { margin-top:0 }
.note_hr { width:80%; border:1px solid gray; }
.prop { padding-left:1em; margin-top:0.5em; margin-bottom:0.5em; }
.quote { border-style:dashed; border-width:0 0 0 1px; padding-left:1em;
         margin-top:0.5em; margin-bottom:0.5em; }
.this { display:none; }

a:link,a:visited { color:black; text-decoration:none; }
a:hover,a:active { text-decoration:underline; }
a:focus { outline:0; } 

:target:before { content:''; display:block; height:0.1em; margin:-0.1em; }
a.link:link, a.link:visited,a.link:active 
{ color:midnightBlue; text-decoration:underline; text-decoration-style:solid; }

.TOC1cols1 { width:80%; max-width:80%; }
.TOC1cols2 { column-count:2; width:80%; max-width:80%; }
.TOC1cols3 { column-count:3; max-width:90%; max-width:90%; }
.TOC1cols4 { column-count:4; max-width:100%; max-width:100%; }
.TOC1table { margin-left:2em; white-space:nowrap; break-inside:auto; }
.TOC1table tr { vertical-align:top; text-align:left; break-inside:avoid; break-after:auto; }
.TOC1table td+td { padding:0 0 0 0.5em; }
.TOC1table .numb { width:3em; max-width:3em; }
.TOC1table .sepr { width:5em; max-width:6em; overflow:hidden; }
.TOC1table .majr { font-weight:bold; }
.TOC1table .text { white-space:normal; }

/* These are due to Firefox (at least <= 76) recalcitrant multi-column handling.
   Web search "Split table into css columns, issue in Firefox" (stackoverflow).
   "Good grief, Charlie Brown!" */
 
.TOC1cols2 table,
.TOC1cols2 tbody,
.TOC1cols2 tr,
.TOC1cols3 table,
.TOC1cols3 tbody,
.TOC1cols3 tr,
.TOC1cols4 table,
.TOC1cols4 tbody,
.TOC1cols4 tr { display:block; padding:0; }

.TOC2cols1 { width:60%; max-width:60%; }
.TOC2cols2 { column-count:2; width:70%; max-width:70%; }
.TOC2cols3 { column-count:3; width:80%; max-width:80%; }
.TOC2cols4 { column-count:4; width:90%; max-width:90%; }
.TOC2table { margin-left:2em; white-space:nowrap; break-inside:auto; }
.TOC2table tr { vertical-align:top; text-align:left; break-inside:avoid; break-after:auto; }
.TOC2table .numb { font-weight:bold; padding-right:0.5em; }
.TOC2table .text { width:100%; white-space:normal; }

/* see "recalcitrant" above */
.TOC2cols2 table,
.TOC2cols2 tbody,
.TOC2cols2 tr,
.TOC2cols3 table,
.TOC2cols3 tbody,
.TOC2cols3 tr,
.TOC2cols4 table,
.TOC2cols4 tbody,
.TOC2cols4 tr { display:block; padding:0; }

.NAVtable { margin:0.1em 0 0 2em; }
.NAVtable td { font-size:110%; font-weight:bold; padding:0; margin:0; }
.NAVtable a { padding:0 0.5em 0 0.5em; text-decoration:none; }

.IDXcols1 { width:80%; max-width:80%; }
.IDXcols2 { column-count:2; width:90%; max-width:90%; }
.IDXcols3 { column-count:3; width:95%; max-width:95%;  }
.IDXcols4 { column-count:4; width:100%; max-width:100%;  }
.IDXtable { margin:1em 0 1em 2em; white-space:nowrap; break-inside:auto; }
.IDXtable tr { vertical-align:top; text-align:left; break-inside:avoid; break-after:auto; }
.IDXtable .alpha { font-weight:bold; min-width:2em; }
.IDXtable .text  { width:100%; white-space:normal; }
.IDXtable .para:before { content:'\00b6\00a0'; }

/* see "recalcitrant" above */
.IDXcols2 table,
.IDXcols2 tbody,
.IDXcols2 tr,
.IDXcols3 table,
.IDXcols3 tbody,
.IDXcols3 tr,
.IDXcols4 table,
.IDXcols4 tbody,
.IDXcols4 tr { display:block; padding:0; }

.insight { background-color:cyan; font-family:monospace;
           padding:0 0.2em 0 0.2em; margin:0 0.2em 0 0.2em;
           font-size:100%; font-style:normal; font-weight:normal;
           text-decoration:none; }

.wasdoc { font-family: "Lucida Console", Monaco, monospace; 
          letter-spacing:-0.07em; }

@media screen { .blank::after { content:"\2924"; } 
                .print { display:none; }
}

@media print {
   table { page-break-inside:avoid; }
   .noprint { display:none; }
   .page { border:none; page-break-after: always; }
   .epage { display:none; }
   .ppage { page-break-after:always; }
   .NAVtable { display:none; }
   .NAVprint { display:block!important; }
}

@page { margin:2cm 1cm 2cm 1cm;  }
</style>
<!-- source:0000_SCRIPTING.WASDOC -->

<style type="text/css">._smiley::after { font-size:150%; vertical-align:middle; content:'\263a' }</style>
<style type="text/css">._frowny::after { font-size:150%; vertical-align:middle; content:'\2639' }</style>

<a id="0." href="#"></a>
<title>WASD Scripting Environment &ndash; WebSocket</title>
<a id="5." href="#"></a>
<a id="5.websocket" href="#"></a>
<a id="websocket" href="#"></a>
<h1 class="head chunk">WASD Scripting Environment</h1>
<h1 class="head"><span class="numb">5.</span><span class="text">WebSocket</span></h1>

<div class="TOC2cols2">
<table class="TOC2table">
<tr><td><a href="scripting005.html#5.1.multiclientwebsocketapplications"><span class="numb">5.1</span><span class="text">Multi-Client WebSocket Applications</span></a>
<tr><td><a href="scripting005.html#5.2.websocketapplication"><span class="numb">5.2</span><span class="text">WebSocket Application</span></a>
<tr><td><a href="scripting005.html#5.3.websocketlibrary"><span class="numb">5.3</span><span class="text">WebSocket Library</span></a>
<tr><td><a href="scripting005.html#5.4.websocketapplicationexamples"><span class="numb">5.4</span><span class="text">WebSocket Application Examples</span></a>
<tr><td><a href="scripting005.html#5.4.1.chat"><span class="numb">5.4.1</span><span class="text">Chat</span></a>
<tr><td><a href="scripting005.html#5.4.2.echo"><span class="numb">5.4.2</span><span class="text">Echo</span></a>
<tr><td><a href="scripting005.html#5.4.3.mouse"><span class="numb">5.4.3</span><span class="text">Mouse</span></a>
<tr><td><a href="scripting005.html#5.5.websocketconfiguration"><span class="numb">5.5</span><span class="text">WebSocket Configuration</span></a>
<tr><td><a href="scripting005.html#5.5.1.websocketthrottle"><span class="numb">5.5.1</span><span class="text">WebSocket Throttle</span></a>
<tr><td><a href="scripting005.html#5.5.2.websocketcommandline"><span class="numb">5.5.2</span><span class="text">WebSocket Command-Line</span></a>
<tr><td><a href="scripting005.html#5.5.3.websocketversion"><span class="numb">5.5.3</span><span class="text">WebSocket Version</span></a>
<tr><td><a href="scripting005.html#5.6.websocketthroughput"><span class="numb">5.6</span><span class="text">WebSocket Throughput</span></a>
<tr><td><a href="scripting005.html#5.7.websocketreferences"><span class="numb">5.7</span><span class="text">WebSocket References</span></a>
<tr><td><a href="scripting005.html#5.8.wasdquotrawquotsocket"><span class="numb">5.8</span><span class="text">WASD &quot;Raw&quot;Socket</span></a>
<tr><td><a href="scripting005.html#5.8.1.rawsocketapplication"><span class="numb">5.8.1</span><span class="text">RawSocket Application</span></a>
<tr><td><a href="scripting005.html#5.8.2.rawsocketlibrary"><span class="numb">5.8.2</span><span class="text">RawSocket Library</span></a>
<tr><td><a href="scripting005.html#5.8.3.rawsocketapplicationexamples"><span class="numb">5.8.3</span><span class="text">RawSocket Application Examples</span></a>
<tr><td><a href="scripting005.html#5.8.3.1.chat"><span class="numb">5.8.3.1</span><span class="text">Chat</span></a>
<tr><td><a href="scripting005.html#5.8.3.2.echo"><span class="numb">5.8.3.2</span><span class="text">Echo</span></a>
<tr><td><a href="scripting005.html#5.8.3.3.terminalserver"><span class="numb">5.8.3.3</span><span class="text">Terminal Server</span></a>
<tr><td><a href="scripting005.html#5.8.4.rawsocketconfiguration"><span class="numb">5.8.4</span><span class="text">RawSocket Configuration</span></a>
</table>
</div>

<table class="NAVtable NAVprint"><tr>
<td><a href="javascript:window.history.back();">&#8617;&#xFE0E;</a>
<td><a href="scripting004.html#4.">&#8598;&#xFE0E;</a>
<td><a href="scripting000.html#0.">&#8593;&#xFE0E;</a>
<td><a href="scripting006.html#6.">&#8600;&#xFE0E;</a>
<td><a href="javascript:window.history.forward();">&#8618;&#xFE0E;</a>
</table>

<p> WebSocket is a capability introduced with HTML5, providing an asynchronous,
bidirectional, full-duplex connection over which messages can be sent between
agents, commonly a browser client and a server application.  Compatible
browsers provide a JavaScript interface that allows connections to be set up,
maintained, messages exchanged, and connections closed down, using a callable
and event-based interface.

<p> WASD provides a WebSocket compatible scripting environment, one that is
activated in the same fashion as an equivalent CGI/CGIplus/RTE and has an
identical CGI environment (variables, streams, etc.) but which uses a unique
HTTP response and communicates with its client using the WebSocket protocol.

<p> Client supplied data is available to the script via the WEBSOCKET_INPUT
mailbox and data from the script supplied via the WEBSOCKET_OUTPUT mailbox
(indicated via CGI variables). Communication using a WebSocket requires the use
of a framing protocol while WEBSOCKET_INPUT and WEBSOCKET_OUTPUT are opaque
octet-streams providing communication to and from the WebSocket application. 
CGI variables WEBSOCKET_INPUT_MRS and WEBSOCKET_OUTPUT_MRS indicate the
respective mailbox capacity.

<p> The WASD server largely acts as a conduit for the WebSocket octet-stream. 
It provides the upgrade from HTTP to WebSocket protocol handshake and then
connects the bidirectional data stream to the WebSocket application activated
in WASD's scripting environment which then is required to perform all of the
protocol requirements, etc.  The baseline WASD implementation is via the
<span class="high bold">wsLIB</span> library (see below).  The complexity and potential extensibility of
the WebSocket protocol means this decoupling of server infrastructure and
protocol implementation offers a number of advantages, including more
straight-forward updates and bug fixing (just the library), and alternate,
concurrent implementations.

<p> Long-lived WebSocket scripts by default have timeouts and other limits set
to infinite.  If control is required it must be exercised using the appropriate
mapping SETings or DCL callouts.

<p> A WASD <span class="high italic">RawSocket</span> is an analogue to the WebSocket, providing a
bidirectional, asynchronous, opaque data stream input and output on a
per-service basis.  See <a class="link" href="scripting005.html#5.8.wasdquotrawquotsocket">5.8 WASD &quot;Raw&quot;Socket</a>. 

<a id="5.1" href="#"></a>
<a id="5.1.multiclientwebsocketapplications" href="#"></a>
<a id="multiclientwebsocketapplications" href="#"></a>
<h2 class="head"><span class="numb">5.1</span><span class="text">Multi-Client WebSocket Applications</span></h2>

<p> A single WASD WebSocket server application (script) can support multiple
clients by using some form of multi-threading such as AST-based I/O, POSIX
Threads, multi-thread interpreter environment, etc.  The WASD wsLIB library
(<a class="link" href="scripting005.html#5.3.websocketlibrary">5.3 WebSocket Library</a>) supports native AST concurrency.

<p> A WebSocket connection to a script is maintained by the WEBSOCKET_INPUT and
WEBSOCKET_OUTPUT channels remaining connected to the script.  If the script
closes them (or the image or process exits, etc.) the WebSocket connection is
closed.  WebSocket requests are maintained as long as the script maintains
them, for a CGIplus script, until it exits.  If a CGIplus script requires to
disconnect from a WebSocket client without exiting it must do so explicitly (by
using the wsLIB <span class="high italic">close</span> function (and associated WebSocket protocol close
handshake), closing C streams, deassigning channels, etc.)

<p> Of course this is the underlying mechanism allowing a single CGIplus script
to maintain connections with multiple WebSocket clients.  Provided the script
remains connected to the WebSocket IPC mailboxes and processes that I/O
asynchronously a single script can concurrently handle multiple clients.  The
script just processes each request it is given, adding the new client to the
existing group (and removing them as the IPC indicates they disconnect).

<p> Obviously the script must remain resident via CGIplus or RTE.

<div class="note">
<a id="5.1.0.0.1" href="#"></a>
<a id="5.1.bytlm" href="#"></a>
<a id="bytlm" href="#"></a>
<h5 class="head center"><span class="text">BYTLM</span></h5>
<hr class="note_hr">
WebSocket scripting environments have the potential to consume significantly
more BYTLM than those for HTTP scripting.  The potentially large number of
mailboxes associated with each scripting process (two per WebSocket connection)
means that server and scripting account(s)  BYTLM and associated quotas will
need to be increased appropriately. 
<hr class="note_hr">
</div>

<p> The server will continue to provide requests to the script for as long as it
appears idle (i.e. the CGIplus sentinal EOF is returned even though concurrent
processing may continue).  Obviously a single scripting process cannot accept
an unlimited number of concurrent WebSockets.  When a script decides it can
process no more it should not return the sentinal EOF from the most recent
request until it is in a position to process more, when it then provides the
EOF and the server again will supply another request.

<p> The original request is access logged at request run-down (when the
WebSocket is finally closed either because the client disconnected or the
script closed its connection to the WEBSOCKET_.. mailboxes).  The access log
status is 101 (Switching Protocols) and the bytes rx and tx reflect the total
for the duration.

<a id="5.2" href="#"></a>
<a id="5.2.websocketapplication" href="#"></a>
<a id="websocketapplication" href="#"></a>
<h2 class="head"><span class="numb">5.2</span><span class="text">WebSocket Application</span></h2>

<p> WebSocket server applications are essentially CGIplus scripts and so have
similar programming considerations (see <a class="link" href="scripting003.html#3.cgiplus">3. CGIplus</a>).

<p> A WebSocket application however is typically long-lived and involves
significant interaction between the participants.  Either party can initiate
independent communication with the other according to the required business
logic.

<p> A WASD WebSocket application relies on asynchronous I/O and other events to
provide the communication granularity required for application interaction. 
The following pseudo-code shows the structure of one such hypothetical
application.  It accepts multiple, concurrent requests in it's main loop,
creates the required WebSocket protocol supporting data structure, and then
services application requirements in two event loops.

<p> The first reads from the remote client and processes according to the
business logic of client-initiated processing, asynchronously and/or
synchronously writing data to the client.  The second loop pushes data
asynchronously to the client based on the application business logic providing
those events.  The close event occurs when the client or application close the
WebSocket, or are otherwise disconnected, and finalises the request.

<div class="blockof code">begin
{
   initialise
   loop
   {
      wait for next client request
      open the WebSocket
      begin asynchronous read from client
      signal ready for another request
   }
}
read event from client
{
   business logic
   asynchronous write to client
   next asynchronous read from client
}
push event to client
{
   business logic
   asynchronous write to client
}
close event
{
   business logic
   close the WebSocket
}
</div>

<p> A second model for request synchronisation allows the initialisation to
specify a routine to be called when another request is available, making all
processing event-driven.  In all other respects the processing is the same as
above.

<div class="blockof code">begin
{
   initialise
   set routine for request acceptance
   hibernate (or otherwise not exit)
}
request acceptance
{
   open the WebSocket
   business logic
   begin asynchronous read from client
   signal ready for another request
}
read event from client
{
   business logic
   asynchronous write to client
   next asynchronous read from client
}
push event to client
{
   business logic
   asynchronous write to client
}
close event
{
   business logic
   close the WebSocket
}
</div>

<p> These basic structures are seen in all the WebSocket example applications.

<a id="5.3" href="#"></a>
<a id="5.3.websocketlibrary" href="#"></a>
<a id="websocketlibrary" href="#"></a>
<h2 class="head"><span class="numb">5.3</span><span class="text">WebSocket Library</span></h2>

<p> <span class="high bold">wsLIB</span> is a C code module that provides the basic infrastructure for
building WebSocket applications to run as WASD scripting under both the models
decribed above.

<p> It abstracts much of the required functionality into a few callable
functions using optional string descriptors so as to minimise dependency on the
C language and on knowing the internals of the library data structure.   The
list of functions and associated parameters would unnecessarily clutter this
document and so WebSocket application designers and programmers are referred to
the descriptive prologue in the library code module itself (see below).  While
wsLIB usage is <span class="high italic">relatively</span> straight-forward, the detail of any
multi-threaded, asynchronous application can be daunting and so the example
WebSocket applications (scripts) should be used as a wsLIB reference and
tutorial.
 
<p> <span class="high bold">wsLIB</span> also contains routines for synchronising request acceptance and
accessing CGI variables associated with that request.  These variables are
available for the period from request acceptance to the issuing of the CGIplus
sentinal EOF indicating to the server the script is ready to accept another
request.  Any CGI variable values required during ongoing processing must be
copied to request-specific storage. Again, the example WebSocket applications
(scripts) should be used as a CGI variable processing reference and tutorial.
 
<p> The library contains WATCH points.  Network [x]Data and [x]Script provide a
useful combination of traffic data.  The library function WsLibWatchScript()
allows WebSocket applications (scripts) to provide additional WATCHable
information via the [x]Script item.

<p class="indent"> <a class="link blank monosp" target="_blank" href="/wasd_root/src/websocket/wslib.c">WASD_ROOT:[SRC.WEBSOCKET]WSLIB.C</a>

<a id="5.4" href="#"></a>
<a id="5.4.websocketapplicationexamples" href="#"></a>
<a id="websocketapplicationexamples" href="#"></a>
<h2 class="head"><span class="numb">5.4</span><span class="text">WebSocket Application Examples</span></h2>

<p> The WASD WebSocket implementation provides a number of scripting examples
illustrating WebSocket programming basics and the use of the WASD wsLIB
library.  All of these illustrate multi-client support using asynchonous I/O. 
Each has a server component (the C code) and a client component (the HTML file
containing the JavaScript code).

<p class="indent"> <a class="link blank monosp" target="_blank" href="/wasd_root/src/websocket/*.*">WASD_ROOT:[SRC.WEBSOCKET]</a>

<p> The following examples concentrate on the server C code as this is
WASD-specific.  Any WebSocket reference can adequitely cover the essentials of
the client JavaScript implementation.

<style type="text/css">._doesws { width:70%; font-size:120%; margin-bottom:0.2em; }</style>
<a id="5.4.0.0.0.1" href="#"></a>
<a id="5.4.websocketdoesthisbrowsersupport" href="#"></a>
<a id="websocketdoesthisbrowsersupport" href="#"></a>
<h6 class="head display0"><span class="text">WebSocket - does this browser support?</span></h6>
<div class="note center">
<a id="5.4.0.0.1" href="#"></a>
<a id="5.4.doesthisbrowsersupportwebsocket" href="#"></a>
<a id="doesthisbrowsersupportwebsocket" href="#"></a>
<h5 class="head center"><span class="text">Does this browser support WebSocket?</span></h5>
<hr class="note_hr">
<div id="websocket_yes" class="_doesws"
style="background-color:#00ff00;display:none;">Y E S</div>
<div id="websocket_yes_but" class="_doesws"
style="background-color:#ffff00;display:none;">
Y E S ... but not a recent enough version</div>
<div id="websocket_no" class="_doesws"
style="background-color:#ff0000;display:inline-block;">N O !</div>
</b>
<br /><script language="JavaScript">
document.write('<i>' + navigator.userAgent + '</i>');
function testWebSocketSupport()
{
   try {
      var ws = new WebSocket("wss://localhost/");
      if (typeof ws.protocol == "undefined")
         return -1;
      else
         return +1;
   }
   catch (err) {
      return 0;
   }
}
function reportWebSocketSupport()
{
   var level = testWebSocketSupport();
   if (level != 0)
      document.getElementById("websocket_no").style.display = "none";
   if (level == +1)
      document.getElementById("websocket_yes").style.display = "inline-block";
   else
   if (level == -1)
      document.getElementById("websocket_yes_but").style.display = "inline-block";
}
if (window.addEventListener)
   window.addEventListener("load", reportWebSocketSupport, false);
else
if (window.attachEvent)
   window.attachEvent("onload", reportWebSocketSupport);
</script>)<hr class="note_hr">
</div>

<a id="5.4.1" href="#"></a>
<a id="5.4.1.chat" href="#"></a>
<a id="chat" href="#"></a>
<h3 class="head"><span class="numb">5.4.1</span><span class="text">Chat</span></h3>

<p> This almost has to be <span class="high bold">the</span> classic example of asynchronous, bidirectional
communications without HTTP kludges.  Each connected client can enter a message
and it is distributed to all connected clients.

<p class="indent"> <a class="link blank monosp" target="_blank" href="/wasd_root/src/websocket/ws_chat.c">WASD_ROOT:[SRC.WEBSOCKET]WS_CHAT.C</a>

<a id="5.4.2" href="#"></a>
<a id="5.4.2.echo" href="#"></a>
<a id="echo" href="#"></a>
<h3 class="head"><span class="numb">5.4.2</span><span class="text">Echo</span></h3>

<p> Each connected client can enter a message which is then returned to them.

<p class="indent"> <a class="link blank monosp" target="_blank" href="/wasd_root/src/websocket/ws_echo.c">WASD_ROOT:[SRC.WEBSOCKET]WS_ECHO.C</a>

<a id="5.4.3" href="#"></a>
<a id="5.4.3.mouse" href="#"></a>
<a id="mouse" href="#"></a>
<h3 class="head"><span class="numb">5.4.3</span><span class="text">Mouse</span></h3>

<p> The HTML/JavaScript/WebSocket client end connects to the script.  Each
mouse movement is then reported to the script.  These data are distributed to
all connected clients.  This provides an asynchronous update facility from all
clients to all clients.

<p> The script is implemented using VMS I/O-driven ASTs.  The code is also
interesting because it implements all required functionality explicitly; no
WebSocket library functions are employed.

<p class="indent"> <a class="link blank monosp" target="_blank" href="/wasd_root/src/websocket/ws_mouse.c">WASD_ROOT:[SRC.WEBSOCKET]WS_MOUSE.C</a>

<a id="5.5" href="#"></a>
<a id="5.5.websocketconfiguration" href="#"></a>
<a id="websocketconfiguration" href="#"></a>
<h2 class="head"><span class="numb">5.5</span><span class="text">WebSocket Configuration</span></h2>

<p> WebSocket server applications are essentially CGIplus scripts and so are
mapped and activated in the same fashion as any other CGIplus script
(<a class="link" href="scripting003.html#3.3.otherconsiderations">3.3 Other Considerations</a>).

<a id="5.5.1" href="#"></a>
<a id="5.5.1.websocketthrottle" href="#"></a>
<a id="websocketthrottle" href="#"></a>
<h3 class="head"><span class="numb">5.5.1</span><span class="text">WebSocket Throttle</span></h3>

<p> Throttle mapping rules may be applied to WebSocket requests.  There is
however, a <span class="high bold">fundamental difference</span> between request throttling and WebSocket
throttling though.  HTTP request throttling applies control to the entire life
of the response.  WebSocket throttling applies only to establishing connection
to the underlying server application.  Once the script responds to accept the
connection or reject it throttling is concluded.

<p> Long-lived WebSocket connections are considered less suitable to full
life-cycle throttling and should use internal mechanisms to control resource
utilisation (i.e. using the delayed sentinal EOF mechanism described in
<a class="link" href="scripting005.html#5.1.multiclientwebsocketapplications">5.1 Multi-Client WebSocket Applications</a>).  Essentially it is used to limit
the impact concurrent requests have on the number of supporting script
processes allowed to be instantiated to support the application.

<p> For example, the rule

<div class="blockof code">set /cgi-bin/ws_application throttle=1
</div>

will only allow one new request at a time attempt to connect to and/or
create a WebSocket application script.  This will effectively limit the number
of supporting processes to one however many clients wish to connect.

<p> To support concurrent requests distributed across multiple application
scripts specify the throttle value as the number of separate scripts

<div class="blockof code">set /cgi-bin/ws_application throttle=5
</div>

and if each script is to support a maximum number of individual connections
then have it delay the EOF sentinal (described above) to block the server
selecting it for the next request.  Requests will be allocated until all
processes have blocked after which they will be queued.

<p> To return a &quot;too busy&quot; 503 to clients (almost) immediately upon all
processes  become full and blocking (maximum application concurrency has been
reached) then set the &quot;t/o-busy&quot; value to 1 second. 

<div class="blockof code">set /cgi-bin/ws_application throttle=5,,,,,1
</div>

<a id="5.5.2" href="#"></a>
<a id="5.5.2.websocketcommandline" href="#"></a>
<a id="websocketcommandline" href="#"></a>
<h3 class="head"><span class="numb">5.5.2</span><span class="text">WebSocket Command-Line</span></h3>

<p> Unconditionally disconnects all WebSocket applications.

<div class="blockof code">&dollar; HTTPD /DO=WEBSOCKET=DISCONNECT
</div>

<p> For VMS V8.2 and later, more selective disconnects are possible. 
Disconnects WebSocket applications with connect number, with matching script
names, and with matching scripting account usernames, respectively.

<div class="blockof code">&dollar; HTTPD /DO=WEBSOCKET=DISCONNECT=<span class="high italic">number</span>
&dollar; HTTPD /DO=WEBSOCKET=DISCONNECT=SCRIPT=<span class="high italic">pattern</span>
&dollar; HTTPD /DO=WEBSOCKET=DISCONNECT=USER=<span class="high italic">pattern</span>
</div>

<a id="5.5.3" href="#"></a>
<a id="5.5.3.websocketversion" href="#"></a>
<a id="websocketversion" href="#"></a>
<h3 class="head"><span class="numb">5.5.3</span><span class="text">WebSocket Version</span></h3>

<p> CGI variable WEBSOCKET_VERSION provides the WebSocket protocol version
number negotiated by the server at connection establishment.

<p> At the time of writing the WebSocket protocol has just gone to IETF Draft
RFC and has during development been very volatile and may continue to be so as
it evolves.  WASD supports the current base protocol number and any higher.  At 
some time in the future it may be necessary to constrain that to a supported
version number or set of numbers.  Defining the logical name
WASD_WEBSOCKET_VERSION to be one or more comma-separated numbers will limit the
supported protocol versions.  For example

<div class="blockof code">&dollar; DEFINE /TABLE=WASD_TABLE WASD_WEBSOCKET_VERSION &quot;10, 9, 8&quot;
</div>

limits requests to protocol version 10 (current), 9 (earlier) and 8 (earliest). 
Logical name is only tested once for each server startup (the first WebSocket
request received).  This logical name only controls server handshake support
and behaviour.  The underlying WebSocket library used by the application (e.g.
wsLIB.c) supports version idiosyncracies for other aspects.

<p> This string is also used as the list of versions reported in a 426 (upgrade
required) response when a client makes a request using an unsupported version.

<a id="5.6" href="#"></a>
<a id="5.6.websocketthroughput" href="#"></a>
<a id="websocketthroughput" href="#"></a>
<h2 class="head"><span class="numb">5.6</span><span class="text">WebSocket Throughput</span></h2>

<p> The raw WebSocket throughput of a platform (hardware plus VMS plus TCP/IP
stack plus WASD and optionally network infrastructure) can be measured using
the WSB utility.  Measures of raw message and byte throughput for a series of
messages of various sizes can provide useful information on the underlying
maximum messaging characteristics of that platform.

<p> The following example shows usage on an Alpha XP1000:

<div class="blockof code">&dollar; WSB == &quot;&dollar;WASD_EXE:WSB&quot;
&dollar; WSB /DO=ECHO /THROUGHPUT /REPEAT=1000 /SIZE=0
%WSB-I-STATS, 1 total connections
Duration: 0.303 seconds
Tx: 1000 msgs at 3303/S, 0 bytes at 0 B/S
Rx: 1000 msgs at 3303/S, 0 bytes at 0 B/S
Total: 2000 msgs at 6607/S, 0 bytes at 0 B/S
&dollar; WSB /DO=ECHO /THROUGHPUT /REPEAT=1000 /SIZE=16
%WSB-I-STATS, 1 total connections
Duration: 0.349 seconds
Tx: 1000 msgs at 2869/S, 16.0 kbytes at 45.9 kB/S
Rx: 1000 msgs at 2869/S, 16.0 kbytes at 45.9 kB/S
Total: 2000 msgs at 5737/S, 32.0 kbytes at 91.8 kB/S
&dollar; WSB /DO=ECHO /THROUGHPUT /REPEAT=1000 /SIZE=64
%WSB-I-STATS, 1 total connections
Duration: 0.359 seconds
Tx: 1000 msgs at 2783/S, 64.0 kbytes at 178.1 kB/S
Rx: 1000 msgs at 2783/S, 64.0 kbytes at 178.1 kB/S
Total: 2000 msgs at 5566/S, 128.0 kbytes at 356.2 kB/S
&dollar; WSB /DO=ECHO /THROUGHPUT /REPEAT=1000 /SIZE=256
%WSB-I-STATS, 1 total connections
Duration: 0.607 seconds
Tx: 1000 msgs at 1646/S, 256.0 kbytes at 421.5 kB/S
Rx: 1000 msgs at 1646/S, 256.0 kbytes at 421.5 kB/S
Total: 2000 msgs at 3293/S, 512.0 kbytes at 843.0 kB/S
&dollar; WSB /DO=ECHO /THROUGHPUT /REPEAT=1000 /SIZE=1024
%WSB-I-STATS, 1 total connections
Duration: 0.659 seconds
Tx: 1000 msgs at 1517/S, 1.0 Mbytes at 1.6 MB/S
Rx: 1000 msgs at 1517/S, 1.0 Mbytes at 1.6 MB/S
Total: 2000 msgs at 3034/S, 2.0 Mbytes at 3.1 MB/S
&dollar; WSB /DO=ECHO /THROUGHPUT /REPEAT=1000 /SIZE=65k
%WSB-I-STATS, 1 total connections
Duration: 10.279 seconds
Tx: 1000 msgs at 97/S, 65.0 Mbytes at 6.3 MB/S
Rx: 1000 msgs at 97/S, 65.0 Mbytes at 6.3 MB/S
Total: 2000 msgs at 195/S, 130.0 Mbytes at 12.6 MB/S
</div>

<p> For more information see the description in the prologue of the program. 
(A zero-size message is legitimate with the WebSocket protocol.)

<a id="5.7" href="#"></a>
<a id="5.7.websocketreferences" href="#"></a>
<a id="websocketreferences" href="#"></a>
<h2 class="head"><span class="numb">5.7</span><span class="text">WebSocket References</span></h2>

<ul class="list">

<li class="item"> <a class="link blank" target="_blank" href="http://en.wikipedia.org/wiki/WebSockets">http://en.wikipedia.org/wiki/WebSockets</a>
<br> Wikipedia overview of WebSockets

<li class="item"> <a class="link blank" target="_blank" href="https://html.spec.whatwg.org/multipage/comms.html#network">https://html.spec.whatwg.org/multipage/comms.html#network</a>
<br> The WebSocket API (JavaScript)

<li class="item"> <a class="link blank" target="_blank" href="http://tools.ietf.org/html/rfc6455">http://tools.ietf.org/html/rfc6455</a>
<br> The WebSocket protocol

<li class="item"> <a class="link blank" target="_blank" href="https://trac.tools.ietf.org/wg/hybi/trac/wiki/FAQ">https://trac.tools.ietf.org/wg/hybi/trac/wiki/FAQ</a>
<br> The IETF WebSocket FAQ

<li class="item"> <a class="link blank" target="_blank" href="http://websocketstest.com/">http://websocketstest.com/</a>
<br> Real-Time Web[socket] Test

</ul>

<a id="5.8" href="#"></a>
<a id="5.8.wasdquotrawquotsocket" href="#"></a>
<a id="wasdquotrawquotsocket" href="#"></a>
<h2 class="head"><span class="numb">5.8</span><span class="text">WASD &quot;Raw&quot;Socket</span></h2>

<p> The WASD <span class="high italic">RawSocket</span> is a variant of, and is heavily based on, the WASD
WebSocket infrastructure.  It allows a service (listening host and port) to
accept a connection and <span class="high italic">immediately</span> activate a configured WASD CGIplus
script to service that connection. Full-duplex, asynchronous, bidirectional
input/output is supported.  While being referred to as a &quot;socket&quot;, of course it
is not network socket communication (BSD or any other abstraction), but a
read/write abstraction via mailbox I/O.  Input is a stream of octets; output a
stream of octets.  The streams are opaque in this context and depend entirely
on the abstraction (protocol) being implemented by the script.  The &quot;RawSocket&quot;
is just WASD nomenclature for WebSocket-style scripting without the WebSocket
protocol.

<div class="note"><a id="5.8.0.0.0.1" href="#"></a>
<a id="5.8.note" href="#"></a>
<a id="note" href="#"></a>
<h5 class="head center"><span class="text">Note</span></h5>
<hr class="note_hr">

A RawSocket application is not intended to use a (standard web) browser as a
client.  Of course the application could (perhaps, also) behave as a web server
if at activation it (also) expected to receive, parse and respond to an HTTP
request, and therefore (also) be used by a web browser client.
<hr class="note_hr">
</div>

<p> The script when activated enters a CGIplus wait-service-wait loop using the
standard CGIplus mechanism.  When a request activates the script it issues a
&quot;100 Continue&quot; CGI/HTTP header to signal the server that the request is
accepted and now being processed.  This header is NOT relayed to the client. 
The activation parameters (normally referred to as <span class="high italic">request</span> parameters) are
available via the usual CGI variables.  The script can then read from and write
to the RAWSOCKET_INPUT and RAWSOCKET_OUTPUT devices respectively.  As with
WebSocket applications, a single RawSocket application (script) can
concurrently support multiple clients.  The end-of-script is indicated by
issuing an EOF to the mailbox.  The script activation can be as long-lived as
required and  the server will not run a request down for any timeout reason.

<a id="5.8.1" href="#"></a>
<a id="5.8.1.rawsocketapplication" href="#"></a>
<a id="rawsocketapplication" href="#"></a>
<h3 class="head"><span class="numb">5.8.1</span><span class="text">RawSocket Application</span></h3>

<p> RawSocket applications share the same lifecycle as described for WebSockets
in <a class="link" href="scripting005.html#5.2.websocketapplication">5.2 WebSocket Application</a>.

<a id="5.8.2" href="#"></a>
<a id="5.8.2.rawsocketlibrary" href="#"></a>
<a id="rawsocketlibrary" href="#"></a>
<h3 class="head"><span class="numb">5.8.2</span><span class="text">RawSocket Library</span></h3>

<p> <span class="high bold">rawLIB</span> is a C code module that provides a similar API and functionality
to the wsLIB library described in <a class="link" href="scripting005.html#5.3.websocketlibrary">5.3 WebSocket Library</a>.

<p class="indent"> <a class="link blank monosp" target="_blank" href="/wasd_root/src/websocket/rawlib.c">WASD_ROOT:[SRC.WEBSOCKET]RAWLIB.C</a>

<a id="5.8.3" href="#"></a>
<a id="5.8.3.rawsocketapplicationexamples" href="#"></a>
<a id="rawsocketapplicationexamples" href="#"></a>
<h3 class="head"><span class="numb">5.8.3</span><span class="text">RawSocket Application Examples</span></h3>

<p> The WASD RawSocket implementation provides a number of scripting examples
illustrating programming basics and the use of the WASD rawLIB library.  All of
these illustrate multi-client support using asynchonouse I/O.  All use
<span class="high italic">telnet</span> as a client interface although this is only for convenience. 
RawSocket is completely protocol agnostic.

<p class="indent"> <a class="link blank monosp" target="_blank" href="/wasd_root/src/websocket/*.*">WASD_ROOT:[SRC.WEBSOCKET]</a>

<a id="5.8.3.1" href="#"></a>
<a id="5.8.3.1.chat" href="#"></a>
<a id="chat" href="#"></a>
<h4 class="head"><span class="numb">5.8.3.1</span><span class="text">Chat</span></h4>

<p> This almost has to be <span class="high bold">the</span> classic example of asynchronous, bidirectional
communications.  Each connected client can enter a message and it is
distributed to all connected clients.

<p class="indent"> <a class="link blank monosp" target="_blank" href="/wasd_root/src/websocket/raw_char.c">WASD_ROOT:[SRC.WEBSOCKET]RAW_CHAT.C</a>

<a id="5.8.3.2" href="#"></a>
<a id="5.8.3.2.echo" href="#"></a>
<a id="echo" href="#"></a>
<h4 class="head"><span class="numb">5.8.3.2</span><span class="text">Echo</span></h4>

<p> Each connected client can enter a message which is then returned to them.

<p class="indent"> <a class="link blank monosp" target="_blank" href="/wasd_root/src/websocket/raw_echo.c">WASD_ROOT:[SRC.WEBSOCKET]RAW_ECHO.C</a>

<a id="5.8.3.3" href="#"></a>
<a id="5.8.3.3.terminalserver" href="#"></a>
<a id="terminalserver" href="#"></a>
<h4 class="head"><span class="numb">5.8.3.3</span><span class="text">Terminal Server</span></h4>

<p> This example implements a simple-minded telnet server.  Definitely not
intended for production.

<p class="indent"> <a class="link blank monosp" target="_blank" href="/wasd_root/src/websocket/raw_ptd.c">WASD_ROOT:[SRC.WEBSOCKET]RAW_PTD.C</a>

<a id="5.8.4" href="#"></a>
<a id="5.8.4.rawsocketconfiguration" href="#"></a>
<a id="rawsocketconfiguration" href="#"></a>
<h3 class="head"><span class="numb">5.8.4</span><span class="text">RawSocket Configuration</span></h3>

<p> RawSocket server applications are essentially CGIplus scripts and so are
mapped and activated in the same fashion as any other CGIplus script
(<a class="link" href="scripting003.html#3.3.otherconsiderations">3.3 Other Considerations</a>).  They are a little unique in that there is
generally a one-to-one relationship between a script and a service.  The
service is flagged as implementing a <span class="high italic">RawSocket</span> and that service is mapped
directly to a script.

<div class="blockof code"># WASD_CONFIG_SERVICE
[[http:*:1234]]
[ServiceRawSocket]  enabled

# WASD_CONFIG_MAP
[[*:1234]]
map * /cgiplus-bin/raw_script
</div>

<p> It is possible to have conditional mapping based on the (rather limited)
&quot;request&quot; parameters (WATCH is useful for understanding what request data is
available).  For example, the script activated may be varied on the client
address.

<div class="blockof code"># WASD_CONFIG_MAP
[[*:1234]]
if (remote-addr:131.185.10.0/24)
   map * /cgiplus-bin/raw_one
else
   map * /cgiplus-bin/raw_two
endif
</div>
<!-- source:0600_CALLOUTS.WASDOC -->

<table class="NAVtable NAVprint"><tr>
<td><a href="javascript:window.history.back();">&#8617;&#xFE0E;</a>
<td><a href="scripting004.html#4.">&#8598;&#xFE0E;</a>
<td><a href="scripting000.html#0.">&#8593;&#xFE0E;</a>
<td><a href="scripting006.html#6.">&#8600;&#xFE0E;</a>
<td><a href="javascript:window.history.forward();">&#8618;&#xFE0E;</a>
</table>