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
Bittensor - an open, decentralized, peer-to-peer network that functions as a market system for the development of artificial intelligence

At Bittensor, we are creating an open, decentralized, peer-to-peer network that functions as a market system for the development of artificial intelligence.

Opentensor 169 Dec 30, 2022
QUIC and HTTP/3 implementation in Python

aioquic What is aioquic? aioquic is a library for the QUIC network protocol in Python. It features a minimal TLS 1.3 implementation, a QUIC stack and

1.2k Dec 29, 2022
GNS3 Graphical Network Simulator

GNS3-gui GNS3 GUI repository.

GNS3 1.7k Dec 29, 2022
9SPY: a Windows RAT built in Python using sockets

9SPY ๐Ÿ‘โ€๐Ÿ—จ 9SPY is a Windows RAT built in Python using sockets Features Features will be listed here soon, there are currenly 14 Information This is a

doop 12 Dec 01, 2022
A benchmark for stateful fuzzing of network protocols

A benchmark for stateful fuzzing of network protocols

3 Apr 25, 2022
This is the code repository for the USENIX Security 2021 paper, "Weaponizing Middleboxes for TCP Reflected Amplification".

weaponizing-censors Censors pose a threat to the entire Internet. In this work, we show that censoring middleboxes and firewalls can be weaponized by

UMD Breakerspace 119 Dec 31, 2022
Visualize the electric field of a point charge network.

ElectriPy โšก Visualize the electric field of a point charges network. ๐Ÿ”Œ Installation Install ElectriPy package: $ pip install electripy You are all d

Dylan Tintenfich 29 Aug 29, 2022
Uses machine learning to scan the similarity of two texts

PlagiarismChecker Uses machine learning to scan the similarity of two documents. End Points: http://localhost:3000/register (create a/c) http://localh

Elvis Chege 2 Aug 10, 2022
A Simple but Powerful cross-platform port scanning & and network automation tool.

DEDMAP is a Simple but Powerful, Clever and Flexible Cross-Platform Port Scanning tool made with ease to use and convenience in mind. Both TCP

Anurag Mondal 30 Dec 16, 2022
Real-time text-editor using python tcp socket

Real-time text-editor using python tcp socket This project does not need any external libraries so you don't need to use virtual environments. All you

MatiYo 3 Aug 05, 2022
A Network tool kit for scanning active IP addresses and open ports

Network scanner A small project that I wrote on the fly for (IT351) Computer Networks University Course to identify and label the devices in my networ

Mohamed Abdelrahman 10 Nov 07, 2022
Test - Python project for Collection Server and API Server

QProjectPython Collection Server ์™€ API Server ๋ฅผ ์œ„ํ•œ Python ํ”„๋กœ์ ํŠธ ์ž…๋‹ˆ๋‹ค. [FastAPI์ฐธ๊ณ ]

1 Jan 03, 2022
Heroku Cloudflare App Domain

Heroku Cloudflare App Domain Creating branded herokuapp.com-like domains using Cloudflare, based on the app name (eg my-app-prod.example.com). Feature

Torchbox 2 Oct 04, 2022
Compare the contents of your hosted and proxy repositories for coordinate collisions

Nexus Repository Manager dependency/namespace confusion checker This repository contains a script to check if you have artifacts containing the same n

Sonatype Community 59 Mar 31, 2022
Una simple herramienta para rastrear IP programada en Python

Spyrod-v2 Una simple herramienta para rastrear IP programada en Python Instalacion apt install git -y cd $HOME git clone https://github.com/Euronymou5

15 Dec 08, 2022
CORS Bypass Proxy Cloud Function

CORS Bypass Proxy Cloud Function

Elayamani K 1 Oct 23, 2021
Quickly fetch your WiFi password and if needed, generate a QR code of your WiFi to allow phones to easily connect

wifi-password Quickly fetch your WiFi password and if needed, generate a QR code of your WiFi to allow phones to easily connect. Works on macOS and Li

Siddharth Dushantha 2.6k Jan 05, 2023
Tool that creates a complete copy of your server

Discord-Server-Cloner Tool that creates a complete copy of your server Setup: Open run.bat If the file closes, open cmd And write: pip install -r requ

DEEM 3 Dec 13, 2021
Wallc - Calculate the layout on the wall to hang up pictures

wallc Calculate the layout on the wall to hang up pictures. Installation pip install git+https://github.com/trbznk/wallc.git Getting Started Currently

Alex Trbznk 68 Sep 09, 2022
ServerStatus with node management and monitor

ServerStatus with node management and monitor

lidalao 162 Jan 01, 2023