socket

WebSocket utilities for real-time bidirectional communication.

Functions

Function
Description
Example

info

Get socket library information

dphelper.socket.info()

start

Initialize and start a socket connection

dphelper.socket.start(element, server, name)

connect

Connect to a WebSocket server

dphelper.socket.connect(server, name)

open

Open a named socket connection

dphelper.socket.open(id, server, name)

send

Send data through socket

dphelper.socket.send(message, type, name)

receive

Set up message receiver

dphelper.socket.receive(element, name)

keepAlive

Maintain connection with ping/pong

dphelper.socket.keepAlive(name)

ping

Send ping to server

dphelper.socket.ping(name)

check

Check and cleanup closed connections

dphelper.socket.check()

list

List all active WebSocket connections

dphelper.socket.list()

Description

Complete WebSocket management toolkit:

  • Connection Management - Connect, disconnect, keep-alive

  • Messaging - Send and receive data

  • Monitoring - Track active connections

  • Security - Enforces WSS (TLS) for production

Usage Examples

Basic Connection

Complete Real-time Chat

Multiple Socket Connections

Keep-Alive Implementation

Form Submission via Socket

Security Features

  • TLS Enforcement - Only allows secure WebSocket connections (wss://)

  • URL Validation - Prevents arbitrary origin connections

  • Same-origin fallback - Supports relative URLs

Details

  • Author: Dario Passariello

  • Version: 0.0.2

  • Creation Date: 20210101

  • Last Modified: 20260220

  • Environment: Client-side only (browser)


Automatically generated document

Last updated