Retro68/gcc/libgo/go/net/sock_windows.go

42 lines
1.2 KiB
Go
Raw Normal View History

// Copyright 2009 The Go Authors. All rights reserved.
2012-03-27 23:13:14 +00:00
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package net
2017-04-10 11:32:00 +00:00
import (
2018-12-28 15:30:48 +00:00
"internal/syscall/windows"
2017-04-10 11:32:00 +00:00
"os"
"syscall"
)
2012-03-27 23:13:14 +00:00
func maxListenerBacklog() int {
// TODO: Implement this
2014-09-21 17:33:12 +00:00
// NOTE: Never return a number bigger than 1<<16 - 1. See issue 5030.
2012-03-27 23:13:14 +00:00
return syscall.SOMAXCONN
}
2017-04-10 11:32:00 +00:00
func sysSocket(family, sotype, proto int) (syscall.Handle, error) {
2018-12-28 15:30:48 +00: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.
2014-09-21 17:33:12 +00:00
// See ../syscall/exec_unix.go for description of ForkLock.
syscall.ForkLock.RLock()
2018-12-28 15:30:48 +00:00
s, err = socketFunc(family, sotype, proto)
2014-09-21 17:33:12 +00:00
if err == nil {
syscall.CloseOnExec(s)
2012-03-27 23:13:14 +00:00
}
2014-09-21 17:33:12 +00:00
syscall.ForkLock.RUnlock()
2017-04-10 11:32:00 +00:00
if err != nil {
return syscall.InvalidHandle, os.NewSyscallError("socket", err)
}
return s, nil
2012-03-27 23:13:14 +00:00
}