send method
Sends data to the server using a WebSocket connection.
Syntax
object.send(data)Parameters
- data [in]
-
Value Meaning Sends a string to the server
Sends a binary stream of data to the server. See msStreamReader.readAsBlob.
Sends a generic fixed-length binary data buffer to the server.
- ArrayBufferView
Sends a variable-length A typed array view of an ArrayBuffer to the server.
Return value
This method does not return a value.
Remarks
An ArrayBufferView is a typed array view of an ArrayBuffer. An ArrayBuffer is a unformatted block of raw data that is sent in its entirety to a server. By using a typed array to define the format of the buffer, and the start and length (number of elements), you can send portions of an ArrayBuffer to a server.
var buf = new ArrayBuffer(100); var firstFourBytes = new Uint8Array(buf, 0, 4); socket.send(firstFourBytes);
This method can throw one of the following exceptions:
| Exception | Description |
|---|---|
| InvalidStateError(11) | The connection is not currently OPEN. |
See also
- FileReader.readAsArrayBuffer
- msStreamReader.readAsBlob
- readyState
- WebSocket
- WebSockets in Windows
- WebSockets RFC 6455
- The WebSocket API
Show: