Socket¶
veltix.socket.core.SocketCore
¶
Bases: Enum
Available socket implementations.
Attributes:
| Name | Type | Description |
|---|---|---|
THREADING |
Standard threading-based socket (default). One thread per connected client. |
|
ASYNC |
Asyncio-based socket (v1.7.0). Single event loop for all connections. |
|
RUST |
Rust core via PyO3 (v3.0.0). Maximum throughput with native Tokio runtime. |
veltix.socket.base_socket.BaseSocket
¶
Bases: Protocol
Protocol defining the interface that all Veltix socket implementations must satisfy.
Any class implementing these methods is automatically considered a valid BaseSocket — no inheritance required. This allows third-party and native implementations (AsyncSocket, RustSocket via PyO3) to conform without depending on Veltix internals.
Implementations are responsible for their own internal configuration (socket options, file descriptors, event loops) — none of that leaks into this interface.
bind
¶
Bind the socket to a local address.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
tuple[str, int]
|
Tuple of (host, port) to bind to. |
required |
accept
¶
Accept an incoming connection.
Blocks until a client connects.
Returns:
| Type | Description |
|---|---|
tuple[BaseSocket, tuple[str, int]]
|
Tuple of (client_socket, (host, port)). |
connect
¶
Connect to a remote server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
tuple[str, int]
|
Tuple of (host, port) to connect to. |
required |
send
¶
Send raw bytes over the socket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
Bytes to send. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the data was sent successfully, False otherwise. |
recv
¶
Receive raw bytes from the socket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buffer_size
|
int
|
Maximum number of bytes to read. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Received bytes, or empty bytes if the connection was closed. |
settimeout
¶
Set a timeout on blocking socket operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Timeout in seconds. Use 0 for non-blocking mode. |
required |
veltix.socket.threading_socket.ThreadingSocket
¶
Threading-based socket implementation for Veltix.
Wraps the standard library socket with the BaseSocket interface. All blocking operations run in dedicated threads managed by the server and client — one thread per connected client.
Internal configuration (SO_REUSEADDR, default timeout) is handled automatically — Server and Client never need to call setsockopt or fileno directly.