trpc.group/trpc-go/trpc-go@v1.0.3/internal/reuseport/reuseport_windows.go (about) 1 // 2 // 3 // Tencent is pleased to support the open source community by making tRPC available. 4 // 5 // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 // All rights reserved. 7 // 8 // If you have downloaded a copy of the tRPC source code from Tencent, 9 // please note that tRPC source code is licensed under the Apache 2.0 License, 10 // A copy of the Apache 2.0 License is included in this file. 11 // 12 // 13 14 //go:build windows 15 // +build windows 16 17 package reuseport 18 19 import ( 20 "net" 21 "syscall" 22 ) 23 24 var ListenerBacklogMaxSize = maxListenerBacklog() 25 26 func maxListenerBacklog() int { 27 return syscall.SOMAXCONN 28 } 29 30 func NewReusablePortListener(proto, addr string) (net.Listener, error) { 31 return net.Listen(proto, addr) 32 } 33 34 func NewReusablePortPacketConn(proto, addr string) (net.PacketConn, error) { 35 return net.ListenPacket(proto, addr) 36 } 37 38 // Listen function is an alias for NewReusablePortListener. 39 func Listen(proto, addr string) (l net.Listener, err error) { 40 return NewReusablePortListener(proto, addr) 41 } 42 43 // ListenPacket is an alias for NewReusablePortPacketConn. 44 func ListenPacket(proto, addr string) (l net.PacketConn, err error) { 45 return NewReusablePortPacketConn(proto, addr) 46 }