added close socket code.

“Too many open files” error fixed.