OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [net/] [sock_linux.go] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2009 The Go Authors.  All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
// Sockets for Linux
6
 
7
package net
8
 
9
import "syscall"
10
 
11
func maxListenerBacklog() int {
12
        fd, err := open("/proc/sys/net/core/somaxconn")
13
        if err != nil {
14
                return syscall.SOMAXCONN
15
        }
16
        defer fd.close()
17
        l, ok := fd.readLine()
18
        if !ok {
19
                return syscall.SOMAXCONN
20
        }
21
        f := getFields(l)
22
        n, _, ok := dtoi(f[0], 0)
23
        if n == 0 || !ok {
24
                return syscall.SOMAXCONN
25
        }
26
        return n
27
}
28
 
29
func listenerSockaddr(s, f int, la syscall.Sockaddr, toAddr func(syscall.Sockaddr) Addr) (syscall.Sockaddr, error) {
30
        a := toAddr(la)
31
        if a == nil {
32
                return la, nil
33
        }
34
        switch v := a.(type) {
35
        case *UDPAddr:
36
                if v.IP.IsMulticast() {
37
                        err := setDefaultMulticastSockopts(s)
38
                        if err != nil {
39
                                return nil, err
40
                        }
41
                        switch f {
42
                        case syscall.AF_INET:
43
                                v.IP = IPv4zero
44
                        case syscall.AF_INET6:
45
                                v.IP = IPv6unspecified
46
                        }
47
                        return v.sockaddr(f)
48
                }
49
        }
50
        return la, nil
51
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.