Prevent closing undefined socket
Merge pull request #5 from loucash/prevent-closing-undefined-socket

Prevent closing undefined socket