Understanding HiSock
#
What is HiSock
? What is it not?#
The TL;DR of this all is:
HiSock
is a higher-level extension of the socket Python module with simpler and more efficient uses.
HiSock
is not a replacement for sockets nor a new network protocol. It doesn’t work through a “request/response” method.
Now, if you’re new to this, most likely you will have no idea what any of this means. But, that’s okay! The goal of this section is to help you understand.
What is the socket
module? How does it relate to HiSock
?#
Let’s focus on what HiSock
is built on, socket
.
socket
is a low-level networking interface that uses “sockets” to communicate between computers over a network. In sockets, when you send data, you need to send a “header” first. Before you even send your data, you need to send some other data telling how long that data is. Along with that, socket
is pretty bare bone. So, I developed HiSock
, which simplifies socket
down and provides additional features.
HiSock
focuses on abstracting the complex parts of sockets so you can focus on what you actually want to do. It does this through managing headers on its own, “type-casting” everything so you don’t have to convert data to bytes and back, event-driven architecture with decorators, threading, data streams, and more. Basically, it’s everything socket
can do, minus the boilerplate code you have to write every time.
How do you send and receive data with HiSock
?#
As HiSock
is an event-driven module, data sent must have a command (also known as event) before the data (not required). An example of this could be if the command is send_number
and the data is 847
.
But what data can be sent? Sockets work with bytes, but most times, you don’t just want bytes. As touched on earlier, HiSock
comes with a type-cast system, which will convert stuff to bytes under-the-hood, so you can focus on sending the data you want and not having to deal with converting it yourself.
Conclusion#
Now that you understand what HiSock
is and why it exists a little better, you can finally start to the Tutorials!