Send BSON serialized data to a pipe

Is there a way to send BSON serialized data to a pipe ?

Writing a BSON to a file can be done with e.g.

using BSON
arr = <somearray>
fname = tempname()
BSON.bson(fname, data = arr)
arr2 = BSON.load(fname)[:data]
rm(fname)

However if I try to write the same array to a Pipe with

server = listen("\\\\.\\pipe\\testiobson")
sock = accept(server)
# need to connect with another process
BSON.bson(sock, data = arr)

I get

MethodError: no method matching bson(::Base.PipeEndpoint; data=<somearray>...

So obviously BSON.bson cannot accept a pipe as a primary argument, but is there a lower lever function that could ? Otherwise, is it possible to wrap this to make it happen ?

Ok, my bad, I had the sequence wrong.

On the reading side

using BSON, Sockets
servername = "\\\\.\\pipe\\testiobson"
server = listen(servername)
sock = accept(server)
var = BSON.load(sock)["data"]

On the writing side

using BSON, Sockets
var = <somevar>
servername = "\\\\.\\pipe\\testiobson"
sock = connect(servername)
BSON.bson(sock, Dict("data" => var))