Class FtpServer
The portable FTP server.
Inherited Members
Namespace: FubarDev.FtpServer
Assembly: FubarDev.FtpServer.dll
Syntax
public sealed class FtpServer : IFtpServer, IPausableFtpService, IFtpService, IDisposable
Constructors
| Improve this Doc View SourceFtpServer(IOptions<FtpServerOptions>, IServiceProvider, IEnumerable<IFtpControlStreamAdapter>, Nullable<ILogger<FtpServer>>)
Initializes a new instance of the FtpServer class.
Declaration
public FtpServer(IOptions<FtpServerOptions> serverOptions, IServiceProvider serviceProvider, IEnumerable<IFtpControlStreamAdapter> controlStreamAdapters, ILogger<FtpServer>? logger = default(ILogger<FtpServer>? ))
Parameters
Type | Name | Description |
---|---|---|
IOptions<FtpServerOptions> | serverOptions | The server options. |
IServiceProvider | serviceProvider | The service provider used to query services. |
IEnumerable<IFtpControlStreamAdapter> | controlStreamAdapters | Adapters for the control connection stream. |
Nullable<ILogger<FtpServer>> | logger | The FTP server logger. |
Properties
| Improve this Doc View SourceMaxActiveConnections
Gets the max allows active connections.
Declaration
public int MaxActiveConnections { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
This will cause connections to be refused if count is exceeded. 0 (default) means no control over connection count.
Port
Gets the port on which the FTP server is listening for incoming connections.
Declaration
public int Port { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
This value is only final after the ListenerStarted event was raised.
Ready
Gets a value indicating whether server ready to receive incoming connections.
Declaration
public bool Ready { get; }
Property Value
Type | Description |
---|---|
Boolean |
ServerAddress
Gets the public IP address (required for PASV
and EPSV
).
Declaration
public string? ServerAddress { get; }
Property Value
Type | Description |
---|---|
Nullable<String> |
Statistics
Gets the FTP server statistics.
Declaration
public IFtpServerStatistics Statistics { get; }
Property Value
Type | Description |
---|---|
IFtpServerStatistics |
Status
Gets the current status.
Declaration
public FtpServiceStatus Status { get; }
Property Value
Type | Description |
---|---|
FtpServiceStatus |
Methods
| Improve this Doc View SourceContinueAsync(CancellationToken)
Continues the FTP service.
Declaration
public Task ContinueAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task | The task. |
Dispose()
Declaration
public void Dispose()
GetConnections()
Returns all connections.
Declaration
public IEnumerable<IFtpConnection> GetConnections()
Returns
Type | Description |
---|---|
IEnumerable<IFtpConnection> | The currently active connections. |
Remarks
The connection might be closed between calling this function and using/querying the connection by the client.
PauseAsync(CancellationToken)
Pauses the FTP service.
Declaration
public Task PauseAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task | The task. |
StartAsync(CancellationToken)
Triggered when the application host is ready to start the service.
Declaration
public Task StartAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Indicates that the start process has been aborted. |
Returns
Type | Description |
---|---|
Task | The task. |
StopAsync(CancellationToken)
Triggered when the application host is performing a graceful shutdown.
Declaration
public Task StopAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Indicates that the shutdown process should no longer be graceful. |
Returns
Type | Description |
---|---|
Task | The task. |
Events
| Improve this Doc View SourceConfigureConnection
Declaration
public event EventHandler<ConnectionEventArgs>? ConfigureConnection
Event Type
Type | Description |
---|---|
Nullable<EventHandler<ConnectionEventArgs>> |
ListenerStarted
Declaration
public event EventHandler<ListenerStartedEventArgs>? ListenerStarted
Event Type
Type | Description |
---|---|
Nullable<EventHandler<ListenerStartedEventArgs>> |
Explicit Interface Implementations
| Improve this Doc View SourceIFtpServer.Start()
Starts the FTP server in the background.
Declaration
[Obsolete("Use IFtpServerHost.StartAsync instead.")]
void IFtpServer.Start()
IFtpServer.Stop()
Stops the FTP server.
Declaration
[Obsolete("Use IFtpServerHost.StopAsync instead.")]
void IFtpServer.Stop()
Remarks
The FTP server cannot be started again after it was stopped.