Fix crash on external connection to socket

If some external entity happened to connect to erld's socket, it would
cause erld to crash. This patch resolves that.