# Bind UDP socket to interface

**URL:** <https://discourse.julialang.org/t/bind-udp-socket-to-interface/79164>\
**Category:** General Usage\
**Tags:** question, networking, c\
**Created:** [April 7, 2022, 12:42pm UTC](https://discourse.julialang.org/t/bind-udp-socket-to-interface/79164 "2022-04-07T12:42:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tine](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@Tine](https://discourse.julialang.org/u/Tine)\
**Post date:** [April 7, 2022, 12:42pm UTC](https://discourse.julialang.org/t/bind-udp-socket-to-interface/79164/1 "2022-04-07T12:42:06Z")

</div>

Is it possible to bind a UDP socket to a specific ethernet interface?  
I looked at the option to call the C-function setsockopt() from Julia using `ccall`, but how do I do this, if this is at all possible?

I want something like this:

```nohighlight
sock = UDPSocket()

# This is not the right syntax, but gives the idea of what I want
i = "eth0"
ccall("setsockop", sock, SO_BINDTODEVICE, i) # bind interface i to socket sock

```
