pywssocks.common module¶
Classes:
Name | Description |
---|---|
PortPool |
A thread-safe port pool for managing available network ports. |
Functions:
Name | Description |
---|---|
init_logging |
Initialize logging with custom format: [mm-dd hh:mm] INFO : msg |
PortPool
¶
A thread-safe port pool for managing available network ports.
This class provides functionality to allocate and release ports from a predefined pool, ensuring thread-safe operations for concurrent access.
Methods:
Name | Description |
---|---|
__init__ |
Args: |
get |
Get an available port from the pool. |
put |
Return a port back to the pool. |
Source code in pywssocks/common.py
__init__(pool)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pool
|
Iterable[int]
|
An iterable of integer port numbers that can be allocated. |
required |
Source code in pywssocks/common.py
get(port=None)
¶
Get an available port from the pool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
port
|
Optional[int]
|
Optional specific port number to request. If None, any available port in the pool will be returned. |
None
|
Returns:
Name | Type | Description |
---|---|---|
port |
Optional[int]
|
The allocated port number, or None if no port is available. |
Source code in pywssocks/common.py
put(port)
¶
Return a port back to the pool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
port
|
int
|
The port number to release back to the pool. |
required |
init_logging(level=logging.INFO)
¶
Initialize logging with custom format: [mm-dd hh:mm] INFO : msg