File: socket_other.go

package info (click to toggle)
golang-github-valyala-tcplisten 0.0~git20210309.652d3b4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 120 kB
  • sloc: makefile: 2
file content (21 lines) | stat: -rw-r--r-- 450 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// +build !darwin

package tcplisten

import (
	"fmt"
	"syscall"
)

func newSocketCloexec(domain, typ, proto int) (int, error) {
	fd, err := syscall.Socket(domain, typ|syscall.SOCK_NONBLOCK|syscall.SOCK_CLOEXEC, proto)
	if err == nil {
		return fd, nil
	}

	if err == syscall.EPROTONOSUPPORT || err == syscall.EINVAL {
		return newSocketCloexecOld(domain, typ, proto)
	}

	return -1, fmt.Errorf("cannot create listening unblocked socket: %s", err)
}