当前位置: 首页>>代码示例>>Golang>>正文


Golang syscall.GetsockoptInt函数代码示例

本文整理汇总了Golang中syscall.GetsockoptInt函数的典型用法代码示例。如果您正苦于以下问题:Golang GetsockoptInt函数的具体用法?Golang GetsockoptInt怎么用?Golang GetsockoptInt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetsockoptInt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: GetsockoptInt

// GetsockoptInt wraps syscall.GetsockoptInt.
func (sw *Switch) GetsockoptInt(s, level, opt int) (soerr int, err error) {
	so := sw.sockso(s)
	if so == nil {
		return syscall.GetsockoptInt(s, level, opt)
	}
	sw.fmu.RLock()
	f, _ := sw.fltab[FilterGetsockoptInt]
	sw.fmu.RUnlock()

	af, err := f.apply(so)
	if err != nil {
		return -1, err
	}
	so.SocketErr, so.Err = syscall.GetsockoptInt(s, level, opt)
	if err = af.apply(so); err != nil {
		return -1, err
	}

	if so.Err != nil {
		return -1, so.Err
	}
	if opt == syscall.SO_ERROR && (so.SocketErr == 0 || syscall.Errno(so.SocketErr) == syscall.EISCONN) {
		sw.smu.Lock()
		sw.stats.getLocked(so.Cookie).Connected++
		sw.smu.Unlock()
	}
	return so.SocketErr, nil
}
开发者ID:tidatida,项目名称:go,代码行数:29,代码来源:sys_unix.go

示例2: TestHubSocksOption

func TestHubSocksOption(t *testing.T) {
	assert := assert.On(t)
	if os.Geteuid() != 0 {
		// This test case requires root permission.
		return
	}

	hub, err := ListenUDP(v2net.LocalHostIP, v2net.Port(0), ListenOption{
		Callback:            func(*buf.Buffer, *proxy.SessionInfo) {},
		ReceiveOriginalDest: true,
	})
	assert.Error(err).IsNil()
	conn := hub.Connection()

	fd, err := internal.GetSysFd(conn)
	assert.Error(err).IsNil()

	val, err := syscall.GetsockoptInt(fd, syscall.SOL_IP, syscall.IP_TRANSPARENT)
	assert.Error(err).IsNil()
	assert.Int(val).Equals(1)

	val, err = syscall.GetsockoptInt(fd, syscall.SOL_IP, syscall.IP_RECVORIGDSTADDR)
	assert.Error(err).IsNil()
	assert.Int(val).Equals(1)
}
开发者ID:v2ray,项目名称:v2ray-core,代码行数:25,代码来源:hub_linux_test.go

示例3: ipv6MulticastLoopback

func ipv6MulticastLoopback(fd int) (bool, error) {
	v, err := syscall.GetsockoptInt(fd, ianaProtocolIPv6, syscall.IPV6_MULTICAST_LOOP)
	if err != nil {
		return false, os.NewSyscallError("getsockopt", err)
	}
	return v == 1, nil
}
开发者ID:98pm,项目名称:docker,代码行数:7,代码来源:sockopt_rfc3493_unix.go

示例4: ipv6MulticastHopLimit

func ipv6MulticastHopLimit(fd int) (int, error) {
	v, err := syscall.GetsockoptInt(fd, ianaProtocolIPv6, syscall.IPV6_MULTICAST_HOPS)
	if err != nil {
		return 0, os.NewSyscallError("getsockopt", err)
	}
	return v, nil
}
开发者ID:98pm,项目名称:docker,代码行数:7,代码来源:sockopt_rfc3493_unix.go

示例5: ipv6TrafficClass

func ipv6TrafficClass(fd int) (int, error) {
	v, err := syscall.GetsockoptInt(fd, ianaProtocolIPv6, syscall.IPV6_TCLASS)
	if err != nil {
		return 0, os.NewSyscallError("getsockopt", err)
	}
	return v, nil
}
开发者ID:98pm,项目名称:docker,代码行数:7,代码来源:sockopt_rfc3493_unix.go

示例6: ipv4MulticastTTL

func ipv4MulticastTTL(fd int) (int, error) {
	v, err := syscall.GetsockoptInt(fd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_TTL)
	if err != nil {
		return 0, os.NewSyscallError("getsockopt", err)
	}
	return v, nil
}
开发者ID:Bobberino,项目名称:musings,代码行数:7,代码来源:sockopt_linux.go

示例7: ipv4SendSourceAddress

func ipv4SendSourceAddress(fd int) (bool, error) {
	v, err := syscall.GetsockoptInt(fd, ianaProtocolIP, syscall.IP_SENDSRCADDR)
	if err != nil {
		return false, os.NewSyscallError("getsockopt", err)
	}
	return v == 1, nil
}
开发者ID:98pm,项目名称:docker,代码行数:7,代码来源:sockopt_freebsd.go

示例8: ipv4MulticastTTL

func ipv4MulticastTTL(fd int) (int, error) {
	v, err := syscall.GetsockoptInt(fd, ianaProtocolIP, sysSockoptMulticastTTL)
	if err != nil {
		return 0, os.NewSyscallError("getsockopt", err)
	}
	return v, nil
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:7,代码来源:sockopt_linux.go

示例9: ipv4MulticastLoopback

func ipv4MulticastLoopback(fd int) (bool, error) {
	v, err := syscall.GetsockoptInt(fd, ianaProtocolIP, sysSockoptMulticastLoopback)
	if err != nil {
		return false, os.NewSyscallError("getsockopt", err)
	}
	return v == 1, nil
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:7,代码来源:sockopt_linux.go

示例10: ipv6ReceivePacketInfo

func ipv6ReceivePacketInfo(fd int) (bool, error) {
	v, err := syscall.GetsockoptInt(fd, ianaProtocolIPv6, syscall.IPV6_2292PKTINFO)
	if err != nil {
		return false, os.NewSyscallError("getsockopt", err)
	}
	return v == 1, nil
}
开发者ID:98pm,项目名称:docker,代码行数:7,代码来源:sockopt_rfc2292_darwin.go

示例11: ipv4ReceiveTOS

func ipv4ReceiveTOS(fd int) (bool, error) {
	v, err := syscall.GetsockoptInt(fd, ianaProtocolIP, sysSockoptReceiveTOS)
	if err != nil {
		return false, os.NewSyscallError("getsockopt", err)
	}
	return v == 1, nil
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:7,代码来源:sockopt_linux.go

示例12: ipv4PacketInfo

func ipv4PacketInfo(fd int) (bool, error) {
	v, err := syscall.GetsockoptInt(fd, syscall.IPPROTO_IP, syscall.IP_PKTINFO)
	if err != nil {
		return false, os.NewSyscallError("getsockopt", err)
	}
	return v == 1, nil
}
开发者ID:Bobberino,项目名称:musings,代码行数:7,代码来源:sockopt_linux.go

示例13: ipv4MulticastLoopback

func ipv4MulticastLoopback(fd int) (bool, error) {
	v, err := syscall.GetsockoptInt(fd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP)
	if err != nil {
		return false, os.NewSyscallError("getsockopt", err)
	}
	return v == 1, nil
}
开发者ID:Bobberino,项目名称:musings,代码行数:7,代码来源:sockopt_linux.go

示例14: ipv6ReceivePathMTU

func ipv6ReceivePathMTU(fd int) (bool, error) {
	v, err := syscall.GetsockoptInt(fd, ianaProtocolIPv6, syscall_IPV6_RECVPATHMTU)
	if err != nil {
		return false, os.NewSyscallError("getsockopt", err)
	}
	return v == 1, nil
}
开发者ID:98pm,项目名称:docker,代码行数:7,代码来源:sockopt_rfc3542_linux.go

示例15: ipv6ReceiveTrafficClass

func ipv6ReceiveTrafficClass(fd int) (bool, error) {
	v, err := syscall.GetsockoptInt(fd, ianaProtocolIPv6, syscall.IPV6_RECVTCLASS)
	if err != nil {
		return false, os.NewSyscallError("getsockopt", err)
	}
	return v == 1, nil
}
开发者ID:98pm,项目名称:docker,代码行数:7,代码来源:sockopt_rfc3542_unix.go


注:本文中的syscall.GetsockoptInt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。