Metadata-Version: 2.1
Name: socket-for-humans
Version: 0.0.1
Summary: A simplified socket setup suitable for many/most lightweight client server programs.The python standard library socket module has a relatively steep learning curve.This module is intended to help get most projects up and running quickly by wrapping the standard library socket module in an easy to use interface.
Home-page: https://gitlab.com/koyaanisqatsi.naqoyqatsi1/socket_for_humans
Author: koyaanisqatsi.naqoyqatsi@pm.me
Author-email: koyaanisqatsi.naqoyqatsi@pm.me
License: MIT
Description: # socket_for_humans
        A simplified socket setup suitable for many/most lightweight client server programs. The python standard library socket module has a relatively steep learning curve. This module will help get most projects up and running quickly by wrapping the Python standard library socket module in an easy to use interface.
        
        `socket_for_humans` is the communications module used in the `simple_gossip` python gossip protocol.
        
        socket_for_humans provides two types of objects `Server` and `Connection`. The `Server` object is used to listen for new connections, while the `Connection` object is used for sending and receiving on both sides of the socket communications once a connection is established.
        
        By default the send and receive functions take/return `str` rather than `bytes`, which is probably what most users initially want, if you want bytes then use `str_mode=False` in the object constructors.
        
        ## Usage:
        
        Essential usage follows this pattern:
        
        ### Example server code:
        ```python
        from socket_for_humans import Server
        
        addr = ('127.0.0.1', 12345)
        my_server = Server(addr)
        while True:
            msg, conn, addr = my_server.get_next()
            if msg:
                # do whatever you need to do with received msg
                print(msg)
                conn.send("here is my reply")
                msg2 = conn.recv()
                print(msg2)
                conn.send("here is my further reply, if you really want to know")
                # continue to use conn to send and receive until the purpose is satisfied.
                conn.close()
        ```
        ### Example client code:
        
        ```python
        from socket_for_humans import Connection
        
        addr = ('127.0.0.1', 12345)
        my_client = Connection(addr)
        my_client.send("a question to the server")
        reply = my_client.recv()
        # continue to use my_client to send and recieve until the purpose is satisfied
        my_client.close()
        ```
Keywords: networking,TCP/IP,simplified,client,server,socket
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: System :: Networking
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown
