Skip to content

Commit

Permalink
feat: close server socket
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj319 committed Dec 26, 2024
1 parent 7ba01f4 commit 3b415ed
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,16 @@ func main() {
log.Fatalf("failed connecting to socket: %v", err)
return
}
defer socket.Close()
log.Printf("Ready to accept connections on file: %s", socketFilePath)
for {
fd, err := socket.Accept()
client, err := socket.Accept()
if err != nil {
log.Fatal("Failed accepting socket %w", err)
}
go func() {
acceptConnection(fd)
fd.Close()
acceptConnection(client)
client.Close()
}()
}
}

0 comments on commit 3b415ed

Please sign in to comment.