16
I’m trying to use Websockets in PHP and Javascript and I’m confused, it uses the protocol Ws:// and wss:// and the server (hostgator) does not have these protocols enabled (I think!) and I can’t get the connection, does anyone know if I need to enable these protocols on the server or how to make the connection ?
I tried to connect to another server I found in examples and got...
Follow the code (with server working):
<script>
var connection = new WebSocket('ws://echo.websocket.org/')
connection.onopen = function(e) {
alert("Connected");
console.log("Connected");
};
connection.onclose = function(e) {
alert("Connection closed");
console.log("Connection closed");
};
</script>
EDIT: Audio streaming is possible using websockets ?
Strange, I tested here on my browser console and it worked normal
– Silvio Andorinha
This example is with another server, my server doesn’t work, but I don’t have any file on the server side to receive the data, nor do I find any file examples to receive the data... I researched a lot but I didn’t really understand how to work with websockets...
– Alan PS
Here’s a full tutorial http://www.html5rocks.com/pt/tutorials/websockets/basics/
– Silvio Andorinha