iftekhs's avatar
Level 13

How does a websocket work?

Hi, I was wondering how does a WebSocket work or how is it made? for example, we use Pusher as a WebSocket service right? so I was curious about how pusher is created, or can I create my own WebSocket?

0 likes
6 replies
sr57's avatar
sr57
Best Answer
Level 39

@iftekhs

I was wondering how does a WebSocket work or how is it made?

You can find a quick answer to most of the questions in this link

https://askinglot.com/what-is-laravel-echo-server

we use Pusher as a WebSocket service right?

You can use this service, it's the main one, https://ably.com is an other one but you can also use you own websocket server with laravel-websocket that uses the same protocol as pusher.

how pusher is created?

Have a look to its "clone" https://github.com/beyondcode/laravel-websockets

1 like
iftekhs's avatar
Level 13

@sr57 Thank you for this can you please give me a kind short explanation of how the connection between server and client is established? like what exactly is it that is constantly listening to the channel?

sr57's avatar

@iftekhs

Depend what you mind by « constantly listinening » but in term of network com, the answer is mainly no, and it’s the main advantage of (web)socket, it reduces bandwidth usage.

It’s a full duplex com, server & client share the same data that are synced on each side. So the client or the server read or write the data from the channel, but there is no network communication except for the server or the client (full duplex) to write the data and some to make the channel works well all the time once it’s opened.

2 good documentations

https://www.tutorialspoint.com/unix_sockets/what_is_socket.htm

https://www.tutorialspoint.com/websockets/websockets_quick_guide.htm

1 like
iftekhs's avatar
Level 13

@sr57 So basically web applications use protocols like FTP, SMTP, etc with WebSockets to establish connection between 2 computers or server and the client, so web sockets itself is a system that allows communication between the server and client right?

Please or to participate in this conversation.