Feature to enable asynchronous event driven network event handling

Implemented asynchronous event driven network handling.

The current network code works well, but relies on what amounts to polling behaviour where one sets up non-blocking sockets, but then have to rely on periodically calling from a timed loop such as emscripten_set_main_loop because select/poll can't have blocking behaviour in an asynchronous environment like JavaScript.

This pull request provides a mechanism to register callbacks for the key network events from both C code and native JavaScript code. The callbacks are linked to the underlying WebSocket callbacks, but they trigger after the emscripten library calls have done their magic. This means that when the message callback triggers for example there will be data in the socket buffer ready to be read.

The various callbacks are passed the file descriptor of the triggering socket, so it is possible to avoid the use of select/poll as the fd is already known, but equally it's possible to use largely unmodified select/poll based code and just use the async callbacks in place of emscripten_set_main_loop. The test case submitted with this pull request uses that approach.

I've also implemented getsockopt with support for SOL_SOCKET/SO_ERROR, which should hopefully resolve https://github.com/kripken/emscripten/issues/2211

The primary use case for this work is to avoid the need for polling network activity, which will improve efficiency and latency for applications that make use of it. It should also make it easier to incorporate emscripten compiled code in other event loops.
Actually none of these callbacks do anything with the websocket message per se, they are pretty much notification callbacks to let the application know that data is available. The problem I'm trying to solve really is that most native C code would tend to write a notification loop that might use say poll set to block, of course you can't block in JavaScript and the emscripten poll/select returns immediately even if NULL is passed. This code calls callbacks that take a file descriptor but actually reading the *data* from the socket would require a read/recv in the callback either using the supplied file descriptor or (as illustrated in the test case) obtaining it via select/poll. I used the latter approach in the test mainly to illustrate how to use the async approach with minimal changes to existing code.

In the case you refer to above the thing being allocated on the stack is just the error message which is generally pretty short of the form 'ECONNREFUSED: Connection refused'. The pattern I'm following here is the one described in https://github.com/kripken/emscripten/wiki/Interacting-with-code#other-methods

Does that make sense?