libgo: update to Go1.10beta1
[official-gcc.git] / libgo / go / net / sock_windows.go
blobfa11c7af2e727c21facca8c6daa2d7b3af9ba672
1 // 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.
5 package net
7 import (
8 "internal/syscall/windows"
9 "os"
10 "syscall"
13 func maxListenerBacklog() int {
14 // TODO: Implement this
15 // NOTE: Never return a number bigger than 1<<16 - 1. See issue 5030.
16 return syscall.SOMAXCONN
19 func sysSocket(family, sotype, proto int) (syscall.Handle, error) {
20 s, err := wsaSocketFunc(int32(family), int32(sotype), int32(proto),
21 nil, 0, windows.WSA_FLAG_OVERLAPPED|windows.WSA_FLAG_NO_HANDLE_INHERIT)
22 if err == nil {
23 return s, nil
25 // WSA_FLAG_NO_HANDLE_INHERIT flag is not supported on some
26 // old versions of Windows, see
27 // https://msdn.microsoft.com/en-us/library/windows/desktop/ms742212(v=vs.85).aspx
28 // for details. Just use syscall.Socket, if windows.WSASocket failed.
30 // See ../syscall/exec_unix.go for description of ForkLock.
31 syscall.ForkLock.RLock()
32 s, err = socketFunc(family, sotype, proto)
33 if err == nil {
34 syscall.CloseOnExec(s)
36 syscall.ForkLock.RUnlock()
37 if err != nil {
38 return syscall.InvalidHandle, os.NewSyscallError("socket", err)
40 return s, nil