可以使用socket选项IP_BIND_ADDRESS_NO_PORT吗?

huangapple go评论82阅读模式
英文:

Can go support the socket option IP_BIND_ADDRESS_NO_PORT

问题

我可以使用C语言的setsockopt(IPPROTO_IP, IP_BIND_ADDRESS_NO_PORT, 1)。但是当我尝试在Golang中做同样的事情时,没有找到IP_BIND_ADDRESS_NO_PORT选项。

英文:

I can use setsockopt(IPPROTO_IP, IP_BIND_ADDRESS_NO_PORT, 1) with C language.
But when I try to do the same thing in golang, there is no option IP_BIND_ADDRESS_NO_PORT.

答案1

得分: 1

IP_BIND_ADDRESS_NO_PORTsys/unix 中被定义为 0x18。

示例代码:

syscall.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.IP_BIND_ADDRESS_NO_PORT, 1)
英文:

The IP_BIND_ADDRESS_NO_PORT is defined in sys/unix

> IP_BIND_ADDRESS_NO_PORT = 0x18

Sample codes

syscall.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.IP_BIND_ADDRESS_NO_PORT, 1)

huangapple
  • 本文由 发表于 2022年10月14日 10:21:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/74063663.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定