2016-07-22 20:15:38 +02:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
2011-05-20 02:18:15 +02:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package net
|
|
|
|
|
2015-10-31 01:59:47 +01:00
|
|
|
import (
|
2018-01-09 02:23:08 +01:00
|
|
|
"internal/syscall/windows"
|
2015-10-31 01:59:47 +01:00
|
|
|
"os"
|
|
|
|
"syscall"
|
|
|
|
)
|
2011-05-20 02:18:15 +02:00
|
|
|
|
2012-01-25 21:56:26 +01:00
|
|
|
func maxListenerBacklog() int {
|
|
|
|
// TODO: Implement this
|
2013-07-16 08:54:42 +02:00
|
|
|
// NOTE: Never return a number bigger than 1<<16 - 1. See issue 5030.
|
2012-01-25 21:56:26 +01:00
|
|
|
return syscall.SOMAXCONN
|
2011-05-20 02:18:15 +02:00
|
|
|
}
|
2012-02-09 09:19:58 +01:00
|
|
|
|
2015-10-31 01:59:47 +01:00
|
|
|
func sysSocket(family, sotype, proto int) (syscall.Handle, error) {
|
2018-01-09 02:23:08 +01:00
|
|
|
s, err := wsaSocketFunc(int32(family), int32(sotype), int32(proto),
|
|
|
|
nil, 0, windows.WSA_FLAG_OVERLAPPED|windows.WSA_FLAG_NO_HANDLE_INHERIT)
|
|
|
|
if err == nil {
|
|
|
|
return s, nil
|
|
|
|
}
|
|
|
|
// WSA_FLAG_NO_HANDLE_INHERIT flag is not supported on some
|
|
|
|
// old versions of Windows, see
|
|
|
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms742212(v=vs.85).aspx
|
|
|
|
// for details. Just use syscall.Socket, if windows.WSASocket failed.
|
|
|
|
|
2013-01-29 21:52:43 +01:00
|
|
|
// See ../syscall/exec_unix.go for description of ForkLock.
|
|
|
|
syscall.ForkLock.RLock()
|
2018-01-09 02:23:08 +01:00
|
|
|
s, err = socketFunc(family, sotype, proto)
|
2013-01-29 21:52:43 +01:00
|
|
|
if err == nil {
|
|
|
|
syscall.CloseOnExec(s)
|
|
|
|
}
|
|
|
|
syscall.ForkLock.RUnlock()
|
2015-10-31 01:59:47 +01:00
|
|
|
if err != nil {
|
|
|
|
return syscall.InvalidHandle, os.NewSyscallError("socket", err)
|
|
|
|
}
|
|
|
|
return s, nil
|
2013-01-29 21:52:43 +01:00
|
|
|
}
|