domnikl/statsd-php — pull request #7 by SteelPangolin (2013-08-15 23:34:45+00:00)
Title: Wrap send() in an exception handler

Although UDP is connectionless, ICMP error responses to StatsD packets (for example, those sent when a StatsD process crashes and there's no longer a listening socket on the port) get treated as errors on the next fwrite() call. In combination with an error handler that converts errors to exceptions, a dead StatsD server can cause the Socket class to throw an unhandled exception and bring down the whole app.

Adding an exception handler around fwrite() in send() covers this case, and shouldn't change behavior if no such error handler is installed.