A Python module that allows you to create and use simple sockets.

Related tags

NetworkingEasySockets
Overview

EasySockets

A Python module that allows you to create and use simple sockets.

Installation

The easysockets module can be installed using pip.

pip install easysockets

or

pip install git+https://github.com/Matthias1590/EasySockets.git

You can also install it by cloning this repository and running the following commands:

python3 setup.py build
python3 setup.py install

Examples

The easysockets module contains 3 main classes: ServerSocket, ClientSocket and Connection. Below are examples on how to use each of them.

ServerSocket:

# The ServerSocket class is used to create a server socket, to create an instance of the ServerSocket class you need a client handler, a client handler is a function that will be passed a connection, the client handler function can then, as the name suggests, handle the client/connection
server_socket = ServerSocket(client_handler=lambda connection: connection.send(b"Hello, world!"))  # This handler just sends "Hello, world!" and then closes the connection

# To make the server socket listen, use the "listen" method. You'll have to specify a host and port
server_socket.listen(host="localhost", port=8080)

# Now whenever a client connects, the lambda we made earlier will be called and will send "Hello, world!" to the client after which it'll close the connection

ClientSocket:

# The ClientSocket class is used to connect to server sockets
client_socket = ClientSocket()

# To connect to a server, use the "connect" method. You'll have to specify the host and port the server is hosted on. This will return a connection that you can then use to communicate with the server
connection = client.connect(host="localhost", port=8080)

# Sending "Hey!" to the server
connection.send(b"Hey!")

# Receiving a message and printing it (NOTE: The message will be received as bytes, to turn it into a string you can use the decode method)
print(connection.receive().decode())

# Closing the connection (NOTE: This isn't necessary if you end the program but it's good practice to do it anyway)
connection.close()

Connection:

# Assume that we just connected to a server
...

# The Connection class is used to communicate to a server/client, whenever you connect to a server or have a client connect to you, you will be given a Connection instance, you cannot create Connections using the constructor

# Send a message (you can only send bytes, if you want to send a string, just encode it)
connection.send("Hello".encode())
# is the same as
connection.send(b"Hello")

# Receive a message
message = connection.receive()
print(message.decode())

# Closing the connection
connection.close()

For more examples, check out example/client.py and example/server.py

Downloads

Downloads Downloads Downloads

Supported Operating Systems

The easysockets module is supported on every operating system as it only uses the built-in socket module.

Owner
Matthias Wijnsma
I'm a self-taught python developer that's always eager to learn!
Matthias Wijnsma
It's a little project for change MAC address, for ethical hacking purposes

MACChangerPy It's a small project for MAC address change, for ethical hacking purposes, don't use it for bad purposes, any infringement will be your r

Erick Adriano Nunes da Silva 1 Mar 11, 2022
IP-Escaner - A Python Tool to obtain information from an IP address

IP-Escaner Herramienta para obtener informacion de una direccion IP Opciones de

4 Apr 09, 2022
Automatically block traffic on Cloudflare's side based on Nginx Log parsing.

AutoRL This is a PoC of automatically block traffic on Cloudflare's side based on Nginx Log parsing. It will evaluate Nginx access.log and find potent

Nova Kwok 62 Dec 28, 2022
Transfer files to and from a Windows host via ICMP in restricted network environments.

ICMP-TransferTools ICMP-TransferTools is a set of scripts designed to move files to and from Windows hosts in restricted network environments. This is

icyguider 269 Dec 20, 2022
DNS monitoring system built with Python.

DNS monitoring system built with Python.

Andressa Cabistani 7 Sep 28, 2021
A simple electrical network analyzer, BASED ON computer-aided design.

Electrical Network Analyzer A simple electrical network analyzer. Given the oriented graph of the electrical network (circut), BASED ON computer-aided

Ahmad Abdulrahman 4 Oct 15, 2022
A simple, personal chat program that runs on a single computer. No Internet, just you.

MultiChat A simple, personal chat program that runs on a single computer. No Internet, just you. Simple and Local MultiChat was created with ease of u

Owls 2 Aug 19, 2022
Mass querying whois records using whois tool

Mass querying whois records using whois tool

Mohamed Elbadry 24 Nov 10, 2022
The Delegate Network: An Interactive Voice Response Delegative Democracy Implementation of Liquid Democracy

The Delegate Network Overview The delegate network is a completely transparent, easy-to-use and understand version of what is sometimes called liquid

James Bowery 2 Feb 25, 2022
netpy - more than implementation of netcat 🐍🔥

netpy - more than implementation of netcat 🐍🔥

Mahmoud S. ElGammal 1 Jan 26, 2022
A simple tool to get information about IP

IP Info Tool Just a simple tool to get IP's information, it uses requests module to gather information about IP, if you dont have much knowledge about

0 Dec 01, 2021
Qobuz-rpc - A simple discord rich presence client for qobuz written in Python

qobuz-rpc A simple discord rich presence client for qobuz written in Python It's

Raphael O. 13 Dec 15, 2022
Web-server with a parser, connection to DBMS, and the Hugging Face.

Final_Project Web-server with parser, connection to DBMS and the Hugging Face. Team: Aisha Bazylzhanova(SE-2004), Arysbay Dastan(SE-2004) Installation

Aisha Bazylzhanova 2 Nov 18, 2021
This script aims to make the dynamic public ip of your local server, public.

EZ DDNS CLOUDFLARE This script aims to make the dynamic ip of your local server, public. It does this by regularly updating cloudflare's dns record. B

3 Feb 13, 2022
A python tool auto change proxy or ip after dealy time set by user

Auto proxy Ghost This tool auto change proxy or ip after dealy time set by user how to run 1. Install required file ./requirements.sh 2.Enter command

Harsh Tagra 0 Feb 23, 2022
The sequel to SquidNet. It has many of the previous features that were in the original script, however a lot of the functions that do not serve much functionality have been removed.

SquidNet2 The sequel to SquidNet. It has many of the previous features that were in the original script, however a lot of the functions that do not se

DrSquidX 5 Mar 25, 2022
NanoChat - nano chat server and client

NanoChat This is a work in progress! NanoChat is an application for connecting with your friends using Python that uses ONLY default Python libraries.

Miss Bliss 1 Nov 13, 2021
IP Pinger - This tool allows you to enter an IP and check if its currently connected to a host

IP Pinger - This tool allows you to enter an IP and check if its currently connected to a host

invasion 3 Feb 18, 2022
Build custom OSINT tools and APIs (Ping, Traceroute, Scans, Archives, DNS, Scrape, Whois, Metadata & built-in database for more info) with this python package

Build custom OSINT tools and APIs with this python package - It includes different OSINT modules (Ping, Traceroute, Scans, Archives, DNS, Scrape, Whoi

QeeqBox 52 Jan 06, 2023
This tool is for finding more detailed information of an IP Address.

This tool is for finding more detailed information of an IP Address.

3 Oct 08, 2021