1// Copyright 2013 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// This file implements sysSocket for platforms that provide a fast path for 6// setting SetNonblock and CloseOnExec. 7 8//go:build dragonfly || freebsd || linux || netbsd || openbsd 9 10package net 11 12import ( 13 "os" 14 "syscall" 15) 16 17// Wrapper around the socket system call that marks the returned file 18// descriptor as nonblocking and close-on-exec. 19func sysSocket(family, sotype, proto int) (int, error) { 20 s, err := socketFunc(family, sotype|syscall.SOCK_NONBLOCK|syscall.SOCK_CLOEXEC, proto) 21 if err != nil { 22 return -1, os.NewSyscallError("socket", err) 23 } 24 return s, nil 25} 26