socket.io documentation code example
Example 1: socket
import socket
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
print('Connected by', addr)
while True:
data = conn.recv(1024)
if not data:
break
conn.sendall(data)
Example 2: socket..io
<script src="https://cdn.socket.io/socket.io-3.0.1.min.js"></script>
Example 3: socket io
npm install --save socket.io
Example 4: socket.io documentation
const socket = new WebSocket('ws://localhost:3000');socket.onopen(() => { socket.send('Hello!');});socket.onmessage(data => { console.log(data);});