Skip to content

Commit abd6db4

Browse files
tobionemith
authored andcommitted
Close the listener after a single request
1 parent 463724b commit abd6db4

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

tcp_server_test.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@ func WithListenServer(t *testing.T, test func(server string)) {
1818
defer l.Close()
1919

2020
go func() {
21-
for {
22-
conn, err := l.Accept()
23-
if err != nil {
24-
fmt.Println("Failed to accept connection: ", err.Error())
25-
continue
26-
}
27-
28-
handleRequest(conn)
21+
conn, err := l.Accept()
22+
if err != nil {
23+
t.Logf("Failed to accept connection: %s", err.Error())
2924
}
25+
26+
handleRequest(conn)
3027
}()
3128

3229
test(server)

0 commit comments

Comments
 (0)