select function: return error condition when network connection fails

With this change the **select** function can report if the network connection failed to set up
(e.g. server down) or if an existing connection gets disconnected (e.g. TCP timeout).

This is especially important as the asynchronous **connect** call cannot report connection setup errors. Such errors need to be diagnosed by the following **select**, **recv**, **send**
calls. This commit here only implements the error handling for the **select** function, as this is as far my test code goes. I didn't look at the **recv** and **send** calls yet.

Note the preceding discussion in https://github.com/kripken/emscripten/pull/857 .