Allows the use of python sockets more easily
Project description
Introduction
This library allows to easily create TCP Servers and Clients using Python sockets
If you want a secure connection, use the secure variant securesockets
. It uses the
pycryptodome library. It should be clear, that you need to install said library to use
the secure variant.
If you have encountered a bug or have an idea, share it on github. For more help look
up the docs
(Note: They may be incomplete)
Installation
use pip install simplesockets
to install this library.
Examples
This package also contains an example, an echo Server and Client:
echoclient.py
if __name__ == "__main__":
from simplesockets import TCPClient
Client = TCPClient()
Client.setup(target_ip="localhost", target_port=25567) #prepares the Client
Client.connect() #connects the Client to the Server
Client.autorecv() #enables autorecv: automaticle saves all incoming data in Client.recved_data,
# return them with Client.return_recved_data()
Client.send_data(b'Test') #sends the text to the Server
while True:
if Client.event.new_data: #checks if any data recved
data = Client.return_recved_data() #returns the recved data as a list
for element in data:
print(element) #should return b'Test'
echoserver.py
if __name__ == "__main__":
from simplesockets import TCPServer
Server = TCPServer()
Server.setup(ip='127.0.0.1',port=25567) #prepares the server
Server.start() #starts the server
while True:
if Server.event.new_data: #checks if any data recved
data = Server.return_recved_data() #returns the recved data as a list
for element in data:
client_socket, address, data = element #data is saved like this (client_socket, address, recved_data)
Server.send_data(data, client_socket)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
simplesockets-0.2.0.tar.gz
(414.1 kB
view hashes)
Built Distribution
simplesockets-0.2.0-py3-none-any.whl
(420.6 kB
view hashes)
Close
Hashes for simplesockets-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1674ae812476aa2e3e52578c128c89a105107c750b6fc6e6d2e0548b3cdabebb |
|
MD5 | ab3528ec48a1bdf2fc0a566d2d1ea7ad |
|
BLAKE2b-256 | e20ca59ecf5c633338adf5367b63b3004c7fe0fb800fc5e47d079da9d587c20b |