The previous recipes show how to create UDP and TCP servers. The sample codes are not ready to handle multiple clients simultaneously. In this recipe, we will cover how to handle more clients at any given time.
Handling multiple clients
How to do it...
- Open the console and create the folder chapter09/recipe03.
- Navigate to the directory.
- Create the multipletcp.go file with the following content:
package main
import (
"fmt"
"log"
"net"
)
func main() {
pc, err := net.ListenPacket("udp", ":7070")
if err != nil {
log.Fatal(err)
}
defer pc.Close()
buffer := make([]byte...