package ch3

import (
	"net"
	"testing"
)

func TestListener(t *testing.T) {
	listener, err := net.Listen("tcp", "0.0.0.0:0")
	if err != nil {
		t.Fatal(err)
	}

	defer func() { _ = listener.Close() }()

	t.Logf("bound to port %q", listener.Addr())

	// example for handling connections and processing connections in a goroutine
	// for {
	// 	conn, err := listener.Accept()
	// 	if err != nil {
	// 		t.Fatal(err)
	// 	}

	// 	go func(c net.Conn) {
	// 		defer c.Close()
	// 		// Your code goes here to handle the connection
	// 	}(conn)
	// }

}
