Skip to content

Commit

Permalink
Fix null datagram address
Browse files Browse the repository at this point in the history
With unix datagrams, apparently the address can be null. Use an empty
string as the address in this case.

Fixes #26

Signed-off-by: Alex Bligh <alex@alex.org.uk>
  • Loading branch information
abligh committed Feb 17, 2016
1 parent e079f55 commit 429245c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ func (s *Server) goReceiveDatagrams(connection net.Conn) {
for ; (n > 0) && (buf[n-1] < 32); n-- {
}
if n > 0 {
s.datagramChannel <- DatagramMessage{buf[:n], addr.String()}
var address string
if addr != nil {
address = addr.String()
}
s.datagramChannel <- DatagramMessage{buf[:n], address}
}
} else {
// there has been an error. Either the server has been killed
Expand Down

0 comments on commit 429245c

Please sign in to comment.