Use stream_get_meta_data to check connection status

Using `stream_get_meta_data` is nicer than checking if our resource type is a "socket" (or a "stream"). This also makes things work in HHVM nicely.