# How to shutdown a socket

**URL:** <https://discourse.julialang.org/t/how-to-shutdown-a-socket/5561>\
**Category:** General Usage\
**Created:** [August 25, 2017, 3:12pm UTC](https://discourse.julialang.org/t/how-to-shutdown-a-socket/5561 "2017-08-25T15:12:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [August 25, 2017, 3:12pm UTC](https://discourse.julialang.org/t/how-to-shutdown-a-socket/5561/1 "2017-08-25T15:12:21Z")

</div>

I’ve been working on a simple example with a Julia server and a C client communicating over a UNIX domain socket. If I call `shutdown(my_socket, SHUT_RDWR)` from the C client, then calling `isopen(my_socket)` in Julia returns `false`, as expected. But if I do try to have the Julia server shutdown the socket by calling `close(my_socket)`, the C client’s pending `recv` call doesn’t return with an error, it just continues to block.

Does `close(my_socket)` not shutdown the socket in a way the client can see? Is there an equivalent to C’s `shutdown` in Julia?

Thank you for the help!

---

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [August 25, 2017, 11:42pm UTC](https://discourse.julialang.org/t/how-to-shutdown-a-socket/5561/2 "2017-08-25T23:42:56Z")

</div>

I had an error in my Julia server - it was blocking trying to read more bytes than the client had sent. So it was never even closing the socket. With that fixed, my C client’s extra `recv` call does receive 0 bytes, as expected.
