Last edit: @kyork in (via web) 7 months ago - Slack Archive

If you're writing a network server, your listen/accept loop should _always_ have this basic form, taken from the Golang `net` package documentation:
```
listener, err := net.Listen("tcp", ":8080")
if err != nil {
	// handle error
}
for {
	conn, err := listener.Accept()
	if err != nil {
		// handle error
	}
	go /* start new thread, calling */ handleConnection(conn)
}
```

History

Revision: 3571 by @kyork in (via web) 7 months agoSlack Archive

If you're writing a network server, your listen/accept loop should _always_ have this basic form, taken from the Golang `net` package documentation:
```
listener, err := net.Listen("tcp", ":8080")
if err != nil {
	// handle error
}
for {
	conn, err := listener.Accept()
	if err != nil {
		// handle error
	}
	go /* start new thread, calling */ handleConnection(conn)
}
```

Revision: 3570 by @kyork in #b_system 7 months agoSlack Archive

If you're writing a network server, your listen/accept loop should _always_ have this basic form, taken from the Golang `net` package documentation: ``` listener, err := net.Listen("tcp", ":8080")
if err != nil {
	// handle error
}
for {
	conn, err := listener.Accept()
	if err != nil {
		// handle error
	}
	go handleConnection(conn)
} ```