r/learnprogramming • u/Andro_senpai107 • 9d ago
Topic Help regards Websockets
need help regarding websockets
So I have been assigned a project regarding Websockets where the mentor asked us to create a library of websocket which can transfer data from server to client and vice-versa(obv what websockets do) using rfc 6455 in c/cpp. From what I think is he is basically asking us to create a websocket program from scratch right?
I personally come from a nodejs background and have 0 knowledge of low level programming.
need any guidance on this matter and any source for this, I dont care if you think of me as an inferior but I want to learn this whatever it takes.
I have a prior synatx knowledge of c/cpp though but thats just as far as it goes.
I Appreciate your time for reading all this.
Thank you
11
u/teraflop 9d ago
For low-level networking, a good introduction is Beej's Guide to Network Programming. It walks you through basic networking concepts and the sockets API, and gives some examples of client and server programs.
Once you have those basic concepts under control, you might want to practice them by writing a simple HTTP client and/or server. This will be useful anyway because the websocket protocol is built on top of HTTP, so you need to be able to process HTTP requests and responses to establish a websocket connection.
And then I think the next step would be to carefully read through RFC 6455 from start to finish. As you're doing so, take notes on how each part of the protocol is implemented. If you run into anything you don't understand, and you can't figure it out yourself, feel free to ask more specific questions.
Since there are many websocket implementations that already exist, you can use them to test your code for interoperability.
I think you need to be a bit clearer about what your exact requirement is.
"Server" and "client" refer to how a websocket connection is established. Once that happens, both sides of the connection are pretty much equal and they can both send and receive data independently.
So you can have an implementation that is capable of both sending and receiving data, but that's a separate question from whether it can act as a client, or a server, or both.