Bind UDP socket to interface

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:

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