I have also been told that Pascal would not be suitable for web programming
This is an incorrect statement, it allows you to solve almost any tasks in the modern web, and pas2js and the future webasm + fresnel confidently allow the language to be at the forefront of progress
I'm not familiar with websocket at all and it seems a bit confusing
If you explain it very simply, then the reason for the appearance of the protocol is the need for reliable constant high-speed two-way data exchange between the browser and the server for real-time applications to work instead of the existing crutches that evolved from hidden frames, then through XMLHttpRequest aka AJAX to the modern Fetch API, but still remained in fact one-sided client -> web server requests.
Why is http used first, which turns into a websocket by the so-called upgrade? Everything is also simple - http will be allowed everywhere, the corresponding ports are always open for it (80, 443), it will pass through any equipment, any DPI. His task is to make a normal request, establish a secure connection, and after that it will no longer be clear which packets are running there (this is of course too simplistic and tls is not a panacea).
In fact, http in this case is just as a disguise in order to eventually allow the client and server to establish a normal two-way connection through ordinary sockets, and websocket itself is a standardized way of exchanging text and binary data through these sockets, aimed at the most efficient (permanent connection + minimal meta data) and reliable (tls + ping-pong keep alive + Close Code + Close Msg) transmission of packets over TCP through a variety of modern heterogeneous networks.
Sorry for the old man's questions but what is the difference between server and client?
Since websockets is a bidirectional protocol, the party establishing the connection is designated as the "client", but when the connection is established, both parties receive equal rights to send/receive messages and close the connection. The semantic load is usually transferred not to the role in establishing the connection, but to the functional load that the server usually serves several clients and provides some services (supports subprotocols), so it needs additional functionality (for example, a pool of multithreaded connections, authorization, etc.). In theory, it is possible to organize a serverless scheme, just with end user clients, but still, the one who will initiate the connection will be the client, and the one who will accept it will be the server until establishing the connection, all this is described in detail in
RFC 6455While I was dealing with the topic, I rewrote a few
examples, maybe they will be useful to you, but they are Windows specific.
For testing purposes take a look at this services:
https://socketsbay.com/test-websocketswss://socketsbay.com/wss/v2/1/demo/ - one way test
wss://socketsbay.com/wss/v2/2/demo/ - ping pong test
and
https://www.postman.com/wss://ws.postman-echo.com/raw/ - ping pong test
P.S. I have written a lot, if anything, correct it
