# Websocket version 1.0 simple examples for local host

**URL:** <https://discourse.julialang.org/t/websocket-version-1-0-simple-examples-for-local-host/20238>\
**Category:** General Usage\
**Created:** [January 29, 2019, 5:57pm UTC](https://discourse.julialang.org/t/websocket-version-1-0-simple-examples-for-local-host/20238 "2019-01-29T17:57:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)\
**Post date:** [January 29, 2019, 6:08pm UTC](https://discourse.julialang.org/t/websocket-version-1-0-simple-examples-for-local-host/20238/2 "2019-01-29T18:08:48Z")

</div>

Maybe [this one](https://discourse.julialang.org/t/which-is-the-right-way-to-integrate-julia-program-with-node-js/19223/4)

```julia
julia> using Sockets

julia> using JSON

julia> pipe = ""

julia> if Sys.iswindows()
           pipe = "\\\\.\\pipe\\testsocket"
       else
           pipe = tempname()
       end
"/var/folders/3z/1kq4lzyd39l1c2gl5c0pzvy80000gp/T/julia0Q6Mrr"

julia> @async begin
           server = listen(pipe)
           while true
               sock = accept(server)
               @async while isopen(sock)
                   input = JSON.parse(sock)
                   JSON.print(sock, Dict("data" => rand(input["input"])))
              end
           end
       end
Task (runnable) @0x000000010b2a61d0

julia> clientside = connect(pipe)
Base.PipeEndpoint(RawFD(0x00000015) open, 0 bytes waiting)

julia> for i in 1:10
           JSON.print(clientside,Dict("input" => i))
           println(JSON.parse(clientside))
       end
Dict{String,Any}("data"=>Any[0.559774])
Dict{String,Any}("data"=>Any[0.89733, 0.513331])
Dict{String,Any}("data"=>Any[0.0675964, 0.381228, 0.618926])
Dict{String,Any}("data"=>Any[0.961195, 0.645998, 0.696614, 0.539933])
Dict{String,Any}("data"=>Any[0.927968, 0.328774, 0.969805, 0.959731, 0.169076])
Dict{String,Any}("data"=>Any[0.33247, 0.929461, 0.162861, 0.270243, 0.827589, 0.666108])
Dict{String,Any}("data"=>Any[0.0766846, 0.996563, 0.299863, 0.996271, 0.904049, 0.622786, 0.315614])
Dict{String,Any}("data"=>Any[0.245844, 0.991654, 0.590529, 0.515608, 0.557779, 0.331809, 0.0752659, 0.205465])
Dict{String,Any}("data"=>Any[0.841952, 0.514019, 0.676124, 0.668515, 0.72262, 0.231272, 0.425817, 0.512281, 0.949894])
Dict{String,Any}("data"=>Any[0.360244, 0.484267, 0.946671, 0.162157, 0.569451, 0.416769, 0.433126, 0.0784071, 0.432733, 0.521421])

julia> 

```

---

_[View the full topic](https://discourse.julialang.org/t/websocket-version-1-0-simple-examples-for-local-host/20238)._
