Winsock listen error

What version of Go are you using (go version)?

What operating system and processor architecture are you using (go env)?

windows xp x86 32bit running in virtualbox.

What did you do?

I start 164 server sockets, listening from TCP addr to
i only got 162 sockets listened ok, 2 failed.
error info : " listen: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full".
but, i wrote another C++ program, do the same thing, and this C++ program can successfully listen on 500 socket ports

the source code:
func ListenMany() {
for i := 0; i < 164; i++ {
go func(i int) {
serverAddr, err := net.ResolveTCPAddr(“tcp”, fmt.Sprintf(“”, i+13000))
if err != nil {

		_, err = net.ListenTCP("tcp", serverAddr)
		if err != nil {
			fmt.Println("listen ", serverAddr, "failed", err)

time.Sleep(time.Second * 10)


i find a solution to the go grogram by setting registry:
[HKEY_LOCAL_MACHINE \System \CurrentControlSet \Services \Tcpip \Parameters]
TcpNumConnections = 65534
then the the Go program can listen on 500 TCP ports.
but this need to reboot the windows xp. and i don’t want user to reboot.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.