WebSocket are more like a two-way conversation that provides full-duplex communication channels over a single TCP connects.
Lets look over a couple of terms. protocol, duplex communication, TCP connections.
-A protocol is an agreement between people on a way in which something is usually done. “Protocol” is just a convention. In this case, a convention for connecting, transmitting, receiving, and disconnecting.
WebSockets use a different protocol from HTTP, one that makes a connection and then keeps it open until you leave the page. It’s a bit confusing because WebSockets actually begin communication over HTTP, but then transparently “upgrade” to the special WebSockets protocol. Communication over this upgraded connection is not the same as the old-school HTTP GET/POST/etc, it’s a special language that supports simultaneous data transfer in both directions.
– A duplex communication refers to the transmission of data in two directions simultaneously. For example, a telephone is a full-duplex device because both parties can talk at once. In contrast to walkie-talkie is half-duplex device because only one party can transmit at a time.
– TCP works with the Internet Protocol (IP), which defines how computers send packets of data to each other. TCP (Transmission Control protocol) is a standard that defines how to establish and maintain a network conversation via which application program can exchange data. TCP works with the Internet Protocol.
Together, TCP and IP are the basic rules defining the Internet.
wrapping I created a web socket client and
This sketch allows a couple of people -using the same local ip address- to play with a frequency’s amplitude. As you move the slider in the index.html, the player should move accordingly.
I defined a class that represents a single caller. The constructor of the Player class takes an argument named socket of type WebSocket.