Some tcp-socket cleaning up

Summary: 
* Better handling of closing
* Improved names of some internal functions
* Simplified read-loop and promise usage
* Give correct errors when they happen
* Correctly stop the accept loop when closed
* Code 'NONE' used for when there is not an error (instead of always saying there is an error)
* No printing of pointless warnings for each internal socket number
* Use early return style rather than else-statements

Fixes: https://github.com/freedomjs/freedom-for-chrome/issues/12

Tested: used with socks-rtc and tested using telnet to the localhost echo-server running in the chrome app.
Also, I would suggest making this simply 'UNKNOWN' as none of the other error codes (in ERROR_MAP) contain zero. You might also consider adding an entry to ERROR_MAP for 0 which maps to UNKNOWN and using that.

(aside: it's very weird that we're using strings for error codes...and, worse, the strings seem unique to this Chrome implementation -- how will this work in Firefox?)