-
-
Save benner/1b71ec1c345753f37d81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "socket" | |
lib LibC | |
ifdef darwin | |
else | |
SO_BINDTODEVICE = 25 | |
end | |
end | |
server = UDPSocket.new | |
iface = "lo" | |
res = LibC.setsockopt(server.fd, LibC::SOL_SOCKET, LibC::SO_BINDTODEVICE, pointerof(iface) as Void*, iface.size) | |
# % strace -qq -f -e trace=setsockopt -e 'signal=!all' crystal run udp.cr | |
# [pid 25840] setsockopt(8, SOL_SOCKET, SO_BINDTODEVICE, "\270x", 2) = -1 EPERM (Operation not permitted) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment