SimpleTCPClient
import random
import time
from simple_socket.tcp_client import SimpleTCPClient # try also SimpleSSLClient for semi-secure communication (it does not verify the cert)
client = SimpleTCPClient('192.168.254.254', 1885)
print('client.Hostname=', client.Hostname)
# by default, the client will connect and attempt to maintain its connection.
# if you want to manually control the connection, pass autoConnect=False
# then use the .Connect() and .Disconnect() methods to manage your connection manually
client.onConnected = lambda _, state: print('The client is', state)
client.onDisconnected = lambda _, state: print('The client is', state)
client.onReceive = lambda _, data: print('Rx:', data)
while True:
cmd = random.choice(['q', 'n', 'i'])
print('sending:', cmd)
if 'Connected' in client.ConnectionStatus:
client.Send(cmd)
time.sleep(5)
SimpleUDPClient
from simple_socket.udp_client import SimpleUDPClient
import time
client1 = SimpleUDPClient('localhost', sendIPPort=1025, receiveIPPort=1024)
def Client1HandleReceive(interface, data):
client1.Send('From client1 echo: {}'.format(data.decode()))
client1.onReceive = Client1HandleReceive
print('client1=', client1)
client2 = SimpleUDPClient('localhost', sendIPPort=1024, receiveIPPort=1025)
client2.onReceive = lambda _, data: print('Rx:', data)
print('client2=', client2)
while True:
client2.Send(f'From client2: The time is {time.asctime()}\r\n')
time.sleep(3)
SimpleTCPServer
from simple_socket.tcp_server import SimpleTCPServer # try also SimpleSSLServer for semi-secure communication (it uses a self-signed cert)
server = SimpleTCPServer(3888)
server.onConnected = lambda client, state: print('Client {} is {}'.format(client, state))
server.onDisconnected = lambda client, state: print('Client {} is {}'.format(client, state))
def HandleRx(client, data):
print('Server received {} from {}'.format(data, client))
client.Send(b'Echo: ' + data + b'\r\n')
if b'q' in data:
# the server can force-close a connection
# in this case,
# the server will disconnect a client if they send the letter 'q'
client.Disconnect()
server.onReceive = HandleRx
Notes
You can pass the parameter “listenAddress” to a Server init. This will allow you to listen to
Metadata
Release files for simple-socket 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simple_socket-0.0.10.tar.gz | 6.6 kB | Without provenance | Details for simple_socket-0.0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_socket-0.0.10-py3-none-any.whl | Python 3 | none | any | Details for simple_socket-0.0.10-py3-none-any.whl |
Total release size: 14.8 kB
Release files / simple_socket-0.0.10.tar.gz
| Download URL | simple_socket-0.0.10.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bfef7431cfa76dcc18d81c502177b4f730ccddd023900321922c6fa49e122ca5
|
|
BLAKE2b-256 checksum How to use checksums |
43bd8bb9241a3f3bdc7dd68e093216d9665286d70c67a7b5c5d183ee30781a77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2
|
Release files / simple_socket-0.0.10-py3-none-any.whl
| Download URL | simple_socket-0.0.10-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6869336f687566c99588865cbad27b3f038a10437b2856ff6ff16d6340385138
|
|
BLAKE2b-256 checksum How to use checksums |
ce2dd65267b1bee9ebac390be465047502ba45d525c54b6667d9258efcaf16c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2
|
Security for simple-socket 0.0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.