Skip to content

Commit

Permalink
update: server
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhnajafiz committed Aug 11, 2022
1 parent 54653a9 commit 0f001a7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
"github.com/amirhnajafiz/stallion/internal"
)

type Server interface {
// Handle method generates a new worker for clients.
Handle(conn net.Conn)
}

// NewServer creates a new broker server on given port.
func NewServer(port string) error {
// creating a new server
Expand All @@ -23,8 +28,10 @@ func NewServer(port string) error {

// handling our clients
for {
conn, _ := listener.Accept()

serve.Handle(conn)
if conn, er := listener.Accept(); er == nil {
serve.Handle(conn)
} else {
log.Printf("error in client accept: %v\n", er)
}
}
}

0 comments on commit 0f001a7

Please sign in to comment.