|
SmartFTP FTP Library
|
Manages a specific range of local ports for Active FTP data connections. More...
import "sfFTPLib.idl";
Public Member Functions | |
| HRESULT | NextPort ([out, retval] long *retval) |
| Retrieves the next available port from the configured pool. | |
| HRESULT | SetPortRange ([in] long minPort, [in] long maxPort) |
| Defines the range of local ports to use. | |
Properties | |
| long | MinPort [get] |
| Retrieves the lower bound of the allowed port range. | |
| long | MaxPort [get] |
| Retrieves the upper bound of the allowed port range. | |
Manages a specific range of local ports for Active FTP data connections.
This interface is used to control which local client-side ports are used when establishing an Active Mode (PORT/EPRT) data connection.
Why use this? In Active FTP, the client opens a random port and asks the server to connect back to it. Firewalls often block these incoming connections on random ports.
By using this interface, you can restrict the client to use a specific range of ports (e.g., 50000-50100) that you have explicitly allowed in your local firewall or NAT router.
| HRESULT IFTPPortPool::NextPort | ( | [out, retval] long * | retval | ) |
Retrieves the next available port from the configured pool.
This method implements a Round-Robin selection strategy:
This ensures that ports are reused evenly, reducing the chance of "Address Already in Use" errors during rapid file transfers.
| [out] | retval | Pointer to a long that receives the next port number to bind. |
| HRESULT IFTPPortPool::SetPortRange | ( | [in] long | minPort, |
| [in] long | maxPort ) |
Defines the range of local ports to use.
Sets the inclusive boundaries for the port pool. The internal iterator is reset to minPort immediately after calling this method.
Validation:
| [in] | minPort | The lowest allowed port number. |
| [in] | maxPort | The highest allowed port number. |
|
getproperty |
Retrieves the upper bound of the allowed port range.
This is the inclusive end value of the pool (e.g., 50100).
| [out] | retval | Pointer to a long that receives the maximum port number. |
|
getproperty |
Retrieves the lower bound of the allowed port range.
This is the inclusive start value of the pool (e.g., 50000).
| [out] | retval | Pointer to a long that receives the minimum port number. |