I am new in programming language. I was trying to create an websocket connection, this is my all line of js

    var url="ws://localhost:8080/WebsocketTests/";
    w= new webSocket(url);

and i got this error:

**C:\xampp\htdocs\WebsocketTests>node test1.js
C:\xampp\htdocs\WebsocketTests\test1.js:3
w= new webSocket(url);
       ^
ReferenceError: webSocket is not defined
at Object.<anonymous> (C:\xampp\htdocs\WebsocketTests\test1.js:3:8)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3**

Please someone can tell me how can i create or make websocket connection easy and with some example.

so how i have to do it ? where i hv done error

ryantroop is referring to the fact that you have a lowercase w in "WebSocket". The system even placed a ^ under the w to let you know that there was a problem.

same problem sir

Did you follow the example in the link I posted?

yes i followed but they said to download this file but i cant find it. this is file pywebsocket-x.x.x/src/mod_pywebsocket

:-/ You sure you're ready to play with web sockets?

Your server should already be set up to handle a socket connection. If it isn't, that's the first thing you need to fix.

The example page I gave you had a good way to make a web socket using javascript, while also doing some error checking in case it is not supported. You don't have to download anything from that page. All you need to do is read the code.

Your server should already be set up to handle a socket connection. If it isn't, that's the first thing you need to fix.

How can i handle that ?

this i took from page

Before you test above client program, you need a server which supports WebSocket.** Download mod_pywebsocket-x.x.x.tar.gz from pywebsocket** which aims to provide a Web Socket extension for Apache HTTP Server ans install it following these steps.

There is actually a standard for websockets. It's an http call that gets upgraded to a persistent connection. Both the software handling the http connection (either Apache or IIS) needs to be up to date to handle this upgrade request, and then you need to write code that actually does something with the persistent connection.

The amount of work required to get you up and running is a bit out of scope for a message board. I would encourage you to use google to find examples of how others have set up their systems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.