From 3b415ed453b6bea48a3d5b1eb85a8ce087dcef7e Mon Sep 17 00:00:00 2001 From: Neeraj319 Date: Thu, 26 Dec 2024 15:05:12 +0000 Subject: [PATCH] feat: close server socket --- server/main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/main.go b/server/main.go index 07a8093..12553e5 100644 --- a/server/main.go +++ b/server/main.go @@ -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() }() } }