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

Subversion Repositories openrisc

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2011 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
// Socket options for Linux
6
 
7
package net
8
 
9
import (
10
        "os"
11
        "syscall"
12
)
13
 
14
func setDefaultSockopts(s, f, t int) error {
15
        switch f {
16
        case syscall.AF_INET6:
17
                // Allow both IP versions even if the OS default is otherwise.
18
                // Note that some operating systems never admit this option.
19
                syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 0)
20
        }
21
 
22
        if f == syscall.AF_UNIX ||
23
                (f == syscall.AF_INET || f == syscall.AF_INET6) && t == syscall.SOCK_STREAM {
24
                // Allow reuse of recently-used addresses.
25
                err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
26
                if err != nil {
27
                        return os.NewSyscallError("setsockopt", err)
28
                }
29
 
30
        }
31
 
32
        // Allow broadcast.
33
        err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)
34
        if err != nil {
35
                return os.NewSyscallError("setsockopt", err)
36
        }
37
 
38
        return nil
39
}
40
 
41
func setDefaultMulticastSockopts(s int) error {
42
        // Allow multicast UDP and raw IP datagram sockets to listen
43
        // concurrently across multiple listeners.
44
        err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
45
        if err != nil {
46
                return os.NewSyscallError("setsockopt", err)
47
        }
48
        return nil
49
}

powered by: WebSVN 2.1.0

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