Metadata-Version: 2.4
Name: FastSocket
Version: 2.0.0
Summary: Librería Python para servidores y clientes TCP/UDP con cifrado híbrido, chunks y transferencia de archivos.
Home-page: https://github.com/giulicrenna/FastSocket
Author: Giuliano Crenna
Author-email: giulicrenna@gmail.com
Project-URL: Documentación, https://giulicrenna.github.io/FastSocket/
Project-URL: Issues, https://github.com/giulicrenna/FastSocket/issues
Keywords: tcp udp socket server client encryption hybrid rsa aes
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Internet
Classifier: Topic :: System :: Networking
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pycryptodome>=3.18.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

![](https://github.com/giulicrenna/FastSocket/blob/main/assets/Design.png)

# FastSocket

FastSocket es una librería Python para construir servidores y clientes TCP y UDP con manejo de múltiples conexiones, cifrado opcional, transferencia por chunks y soporte de archivos. La API está pensada para ser mínima y rápida de usar.

## Features

- API simple para servidores y clientes TCP y UDP
- Comunicación segura con cifrado RSA
- Modo TLS Hybrid: intercambio de clave RSA-4096 + cifrado AES-256-GCM + autenticación HMAC
- ChunkManager para dividir y reensamblar payloads grandes
- FileTransfer con verificación de integridad (SHA-256)
- Soporte UDP unicast y broadcast
- Ejemplos, benchmarks y stress tests incluidos

## Roadmap

* [ ] Implementación con asyncio
* [ ] Gestión automática de chunks en el protocolo base
* [ ] Reconexión automática en clientes
* [ ] Keep-alive configurable
* [ ] Políticas de rate limiting
* [ ] Serialización de mensajes (JSON, MessagePack)
* [ ] Compresión de payloads (zlib / lz4)

## Instalación

```bash
pip install FastSocket
```

## Quickstart

**Servidor TCP:**

```python
from FastSocket import FastSocketServer, SocketConfig, Queue

def handle_messages(messages: Queue):
    while not messages.empty():
        msg, addr = messages.get()
        print(f"[{addr}] {msg}")
        server.send_msg_stream(f"Echo: {msg}")

config = SocketConfig(host="localhost", port=8080)
server = FastSocketServer(config)
server.on_new_message(handle_messages)
server.start()
```

**Cliente TCP:**

```python
from FastSocket import FastSocketClient, SocketConfig

def on_message(msg: str):
    print("Servidor:", msg)

client = FastSocketClient(SocketConfig(host="localhost", port=8080))
client.on_new_message(on_message)
client.start()
client.send_to_server("hola")
```

## Modo TLS Hybrid

```python
from FastSocket import TLSSocketServer, TLSSocketClient, SocketConfig

# Servidor
server = TLSSocketServer(SocketConfig(host="localhost", port=9443), shared_secret="secreto-fuerte")
server.on_new_message(lambda q: print(q.get()))
server.start()

# Cliente
client = TLSSocketClient(SocketConfig(host="localhost", port=9443), shared_secret="secreto-fuerte")
client.on_new_message(lambda msg: print(msg))
client.start()
```

## UDP

```python
from FastSocket import FastSocketUDPServer, SocketConfig
import socket

config = SocketConfig(host="0.0.0.0", port=9000, type=socket.SOCK_DGRAM)
server = FastSocketUDPServer(config, enable_broadcast=True)
server.start()
```

## Documentación

Documentación completa en [giulicrenna.github.io/FastSocket](https://giulicrenna.github.io/FastSocket/)

## Contribuir

Los pull requests son bienvenidos. Antes de enviar, asegurate de que los tests pasen y de seguir el estilo PEP 8.

## Contacto

**Autor:** Giuliano Crenna  
**Email:** giulicrenna@gmail.com

## Licencia

Este proyecto está licenciado bajo GNU Affero General Public License v3.0 (AGPL-3.0). Ver el archivo LICENSE para más detalles.
