error and nil checks on socket connection

This commit is contained in:
Shlomi Noach 2017-04-13 08:27:42 +03:00
parent 3313cb3933
commit 3092e9c5c0

View File

@ -98,8 +98,13 @@ func (this *Server) Serve() (err error) {
}
func (this *Server) handleConnection(conn net.Conn) (err error) {
defer conn.Close()
if conn != nil {
defer conn.Close()
}
command, _, err := bufio.NewReader(conn).ReadLine()
if err != nil {
return err
}
return this.onServerCommand(string(command), bufio.NewWriter(conn))
}