本文整理汇总了Golang中golang.org/x/net/internal/netreflect.SocketOf函数的典型用法代码示例。如果您正苦于以下问题:Golang SocketOf函数的具体用法?Golang SocketOf怎么用?Golang SocketOf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SocketOf函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: SetTTL
// SetTTL sets the time-to-live field value for future outgoing
// packets.
func (c *genericOpt) SetTTL(ttl int) error {
if !c.ok() {
return syscall.EINVAL
}
s, err := netreflect.SocketOf(c.Conn)
if err != nil {
return err
}
return setInt(s, &sockOpts[ssoTTL], ttl)
}
开发者ID:ehalpern,项目名称:go-mysql-elasticsearch,代码行数:12,代码来源:genericopt_posix.go
示例2: TTL
// TTL returns the time-to-live field value for outgoing packets.
func (c *genericOpt) TTL() (int, error) {
if !c.ok() {
return 0, syscall.EINVAL
}
s, err := netreflect.SocketOf(c.Conn)
if err != nil {
return 0, err
}
return getInt(s, &sockOpts[ssoTTL])
}
开发者ID:ehalpern,项目名称:go-mysql-elasticsearch,代码行数:11,代码来源:genericopt_posix.go
示例3: SetHopLimit
// SetHopLimit sets the hop limit field value for future outgoing
// packets.
func (c *genericOpt) SetHopLimit(hoplim int) error {
if !c.ok() {
return syscall.EINVAL
}
s, err := netreflect.SocketOf(c.Conn)
if err != nil {
return err
}
return setInt(s, &sockOpts[ssoHopLimit], hoplim)
}
开发者ID:ehalpern,项目名称:go-mysql-elasticsearch,代码行数:12,代码来源:genericopt_posix.go
示例4: SetTrafficClass
// SetTrafficClass sets the traffic class field value for future
// outgoing packets.
func (c *genericOpt) SetTrafficClass(tclass int) error {
if !c.ok() {
return syscall.EINVAL
}
s, err := netreflect.SocketOf(c.Conn)
if err != nil {
return err
}
return setInt(s, &sockOpts[ssoTrafficClass], tclass)
}
开发者ID:ehalpern,项目名称:go-mysql-elasticsearch,代码行数:12,代码来源:genericopt_posix.go
示例5: PathMTU
// PathMTU returns a path MTU value for the destination associated
// with the endpoint.
func (c *Conn) PathMTU() (int, error) {
if !c.genericOpt.ok() {
return 0, syscall.EINVAL
}
s, err := netreflect.SocketOf(c.genericOpt.Conn)
if err != nil {
return 0, err
}
_, mtu, err := getMTUInfo(s, &sockOpts[ssoPathMTU])
if err != nil {
return 0, err
}
return mtu, nil
}
开发者ID:Rudloff,项目名称:platform,代码行数:16,代码来源:endpoint.go
示例6: TestSocketOf
func TestSocketOf(t *testing.T) {
for _, network := range []string{"tcp", "unix", "unixpacket"} {
switch network {
case "unix":
switch runtime.GOOS {
case "nacl", "plan9", "windows":
continue
}
case "unixpacket":
switch runtime.GOOS {
case "darwin", "nacl", "plan9", "windows":
continue
}
}
ln, err := newLocalListener(network)
if err != nil {
t.Error(err)
continue
}
defer func() {
path := ln.Addr().String()
ln.Close()
if network == "unix" || network == "unixpacket" {
os.Remove(path)
}
}()
c, err := net.Dial(ln.Addr().Network(), ln.Addr().String())
if err != nil {
t.Error(err)
continue
}
defer c.Close()
if _, err := netreflect.SocketOf(c); err != nil {
t.Error(err)
continue
}
}
}
开发者ID:mozilla-services,项目名称:userplex,代码行数:38,代码来源:socket_test.go
注:本文中的golang.org/x/net/internal/netreflect.SocketOf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论