# Send BSON serialized data to a pipe

**URL:** <https://discourse.julialang.org/t/send-bson-serialized-data-to-a-pipe/62381>\
**Category:** New to Julia\
**Tags:** question, bson, serialization\
**Created:** [June 4, 2021, 8:46am UTC](https://discourse.julialang.org/t/send-bson-serialized-data-to-a-pipe/62381 "2021-06-04T08:46:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [June 4, 2021, 8:46am UTC](https://discourse.julialang.org/t/send-bson-serialized-data-to-a-pipe/62381/1 "2021-06-04T08:46:25Z")

</div>

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

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

```julia
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

```julia
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 ?

---

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [June 4, 2021, 10:35am UTC](https://discourse.julialang.org/t/send-bson-serialized-data-to-a-pipe/62381/2 "2021-06-04T10:35:13Z")

</div>

Ok, my bad, I had the sequence wrong.

On the reading side

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

```

On the writing side

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

```
