private void serverSocket_OnCommandReceived(ITftpCommand command, EndPoint endpoint) { //Ignore all other commands if (!(command is ReadOrWriteRequest)) { return; } //Open a connection to the client ITransferChannel channel = TransferChannelFactory.CreateConnection(endpoint, new IPEndPoint(localInterface, 0)); //Create a wrapper for the transfer request ReadOrWriteRequest request = (ReadOrWriteRequest)command; ITftpTransfer transfer = request is ReadRequest ? (ITftpTransfer) new LocalReadTransfer(channel, request.Filename, request.Options) : new LocalWriteTransfer(channel, request.Filename, request.Options); if (command is ReadRequest) { RaiseOnReadRequest(transfer, endpoint); } else if (command is WriteRequest) { RaiseOnWriteRequest(transfer, endpoint); } else { throw new Exception("Unexpected tftp transfer request: " + command); } }
private void ServerSocket_OnCommandReceived(ITFtpCommand command, EndPoint endpoint) { // Ignore all other commands if (!(command is ReadOrWriteRequest)) { return; } // Open a connection to the client ITransferChannel channel = TransferChannelFactory.CreateConnection(endpoint); // Create a wrapper for the transfer request ReadOrWriteRequest request = (ReadOrWriteRequest)command; ITFtpTransfer transfer = request is ReadRequest ? (ITFtpTransfer) new LocalReadTransfer(channel, request.Filename, request.Options) : new LocalWriteTransfer(channel, request.Filename, request.Options); switch (command) { case ReadRequest _: RaiseOnReadRequest(transfer, endpoint); break; case WriteRequest _: RaiseOnWriteRequest(transfer, endpoint); break; default: throw new Exception($"Unexpected TFTP transfer request: {command}"); } }
public TftpServer(IPEndPoint localAddress) { if (localAddress == null) { throw new ArgumentNullException("localAddress"); } serverSocket = TransferChannelFactory.CreateServer(localAddress); serverSocket.OnCommandReceived += new TftpCommandHandler(serverSocket_OnCommandReceived); serverSocket.OnError += new TftpChannelErrorHandler(serverSocket_OnError); }
public TFtpServer(IPEndPoint localAddress) { if (localAddress == null) { throw new ArgumentNullException(nameof(localAddress)); } m_serverSocket = TransferChannelFactory.CreateServer(localAddress); m_serverSocket.OnCommandReceived += ServerSocket_OnCommandReceived; m_serverSocket.OnError += ServerSocket_OnError; }
public TFtpTransfer(ITransferChannel connection, string filename, ITransferState initialState) { ProposedOptions = TransferOptionSet.NewDefaultSet(); Filename = filename; RetryCount = 5; SetState(initialState); Connection = connection; Connection.OnCommandReceived += Connection_OnCommandReceived; Connection.OnError += Connection_OnError; Connection.Open(); Timer = new Timer(Timer_OnTimer, null, 500, 500); }
public TftpTransfer(ITransferChannel connection, String filename, ITransferState initialState) { this.ProposedOptions = TransferOptionSet.NewDefaultSet(); this.Filename = filename; this.RetryCount = 5; this.SetState(initialState); this.connection = connection; this.connection.OnCommandReceived += new TftpCommandHandler(connection_OnCommandReceived); this.connection.OnError += new TftpChannelErrorHandler(connection_OnError); this.connection.Open(); this.timer = new Timer(timer_OnTimer, null, 500, 500); }
public TftpServer(IPEndPoint localAddress, TimeSpan timeout) { if (localAddress == null) { throw new ArgumentNullException("localAddress"); } Timeout = (int)timeout.TotalMilliseconds; serverSocket = TransferChannelFactory.CreateServer(localAddress); serverSocket.OnCommandReceived += new TftpCommandHandler(serverSocket_OnCommandReceived); serverSocket.OnError += new TftpChannelErrorHandler(serverSocket_OnError); }
/// <summary> /// PUT a file from the server. /// You have to call Start() on the returned ITFtpTransfer to start the transfer. /// </summary> public ITFtpTransfer Upload(string filename) { ITransferChannel channel = TransferChannelFactory.CreateConnection(m_remoteAddress); return(new RemoteWriteTransfer(channel, filename)); }
public LocalReadTransfer(ITransferChannel connection, string filename, IEnumerable <TransferOption> options) : base(connection, filename, new StartIncomingRead(options)) { }
public RemoteReadTransfer(ITransferChannel connection, string filename) : base(connection, filename, new StartOutgoingRead()) { }
/// <summary> /// GET a file from the server. /// You have to call Start() on the returned ITftpTransfer to start the transfer. /// </summary> public ITftpTransfer Download(String filename) { ITransferChannel channel = TransferChannelFactory.CreateConnection(remoteAddress); return(new RemoteReadTransfer(channel, filename)); }
public RemoteWriteTransfer(ITransferChannel connection, string filename) : base(connection, filename, new StartOutgoingWrite()) { }
/// <summary> /// GET a file from the server via the specific local interface. /// You have to call Start() on the returned ITftpTransfer to start the transfer. /// </summary> public ITftpTransfer Download(String filename, IPAddress localInterface) { ITransferChannel channel = TransferChannelFactory.CreateConnection(remoteAddress, new IPEndPoint(localInterface, 0)); return(new RemoteReadTransfer(channel, filename)); }
/// <summary> /// PUT a file from the server. /// You have to call Start() on the returned ITftpTransfer to start the transfer. /// </summary> public ITftpTransfer Upload(String filename) { ITransferChannel channel = TransferChannelFactory.CreateConnection(remoteAddress, new IPEndPoint(IPAddress.Any, 0)); return(new RemoteWriteTransfer(channel, filename)); }