Metadata-Version: 2.1
Name: socket-api2
Version: 0.1.3
Summary: Socket Api 2 creates the best connection between a server and client/clients, and its compatible with ngrok (pyngrok)
Home-page: UNKNOWN
Author: Da4ndo
Author-email: da4ndo0@gmail.com
License: UNKNOWN
Keywords: socket_api2,socket,socket_api,socket api,socket api 2
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Education
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown
License-File: LICENSE.txt

# Socket Api 2

**Socket Api 2** creates the best connection between a server and client/clients.

Supported language is python 3. (Package wrote in 3.9-3.10.1)

- Checks if client is still connected.
- If server is not responding more, there is a feature that the client tries to reconnect. ***(optional)***
- Colored Logging in console/file. ***(optional)***

## Installation

Use this command:

    pip install socket-api2

## Change Log

0.1.3 (01/24/2022):

- Fixed ngrok usage

0.1.2 (01/07/2022):

- Optimized
- Added KeyboardInterrupt parsing.
- Fixed some bugs

0.1.1 (10/16/2021):

- Fixed bugs

## Examples

Difference between SEND_METHOD.default_send and SEND_METHOD.just_send, with the default send the program send a lenght of the message then send the message to know how many bytes we need to receive, but the just_send is just send the message. 

Example for Server:

    from socket_api2 import *

    server = Server(ip="auto", port=5555)

    @server.on_client_connect()
    def handling_client(client):
        while True:
            if client.is_connected:
                msg = client.recv(2048)
                if msg == "hi":
                    client.send("hi 2", method=SEND_METHOD.default_send)
                
                elif msg == "I love u":
                    client.send("I love u too")

                else:
                    client.send("no hi", method=SEND_METHOD.just_send)
            else:
                break

    server.start()

Example for Client:

    from socket_api2 import *

    client = Client(target_ip="IP", target_port=5555, timeout=10)
    resp, error = client.connect()
    if resp == 200:
        client.send("hi")
        client.recv(2048)

        client.send("I love u", method=SEND_METHOD.just_send)
        client.recv(2048)
    else:
        outstr("ERROR", f"Something went wrong... --> {error}")

