# quicproquo Python FFI Client

Python wrapper around `libquicproquo_ffi` using `ctypes`.

## Build the FFI library

```bash
cargo build --release -p quicproquo-ffi
```

This produces:

- Linux: `target/release/libquicproquo_ffi.so`
- macOS: `target/release/libquicproquo_ffi.dylib`
- Windows: `target/release/quicproquo_ffi.dll`

## Usage

```bash
python examples/python/qpq_client.py \
    --server 127.0.0.1:7000 \
    --ca-cert server-cert.der \
    --server-name localhost \
    --username alice \
    --password secret
```

### Send a message

```bash
python examples/python/qpq_client.py \
    --server 127.0.0.1:7000 \
    --ca-cert server-cert.der \
    --username alice --password secret \
    --send-to bob --message "hello from Python"
```

### Receive messages

```bash
python examples/python/qpq_client.py \
    --server 127.0.0.1:7000 \
    --ca-cert server-cert.der \
    --username bob --password secret \
    --receive --timeout 10000
```

## Library path

The script auto-detects the library in `target/release/` or `target/debug/`.
Override with `QPQ_FFI_LIB`:

```bash
export QPQ_FFI_LIB=/path/to/libquicproquo_ffi.so
```

## Programmatic usage

```python
from qpq_client import QpqClient, _find_library, _load_library

lib = _load_library(_find_library())
with QpqClient(lib) as client:
    client.connect("127.0.0.1:7000", "server-cert.der", "localhost")
    client.login("alice", "secret")
    client.send("bob", "hello")
    messages = client.receive(timeout_ms=5000)
```
