Giter VIP home page Giter VIP logo

ftp's People

Contributors

juchiast avatar qcuong98 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

ftp's Issues

Cài các hàm trong class Ftp

  • Gửi 1 file
  • Nhận 1 file
  • Xóa 1 file
  • Xóa thư mục
  • Tạo thư mục
  • In đường dẫn hiện tại trên server
  • Chuyển đường dẫn hiện tại trên server
  • Thoát server

Các lệnh không cần giao tiếp với server:

  • Chuyển thư mục hiện tại ở client.
  • In thư mục hiện tại ở client.
  • Chuyển trạng thái thành active
  • Chuyển trạng thái thành passive
  • Gửi, nhận, xóa nhiều file (gọi lại hàm 1 file tương ứng)

Cài nonblock

Thầy yêu cầu chương trình chạy thông suốt, không bị đứng.

Phần này sẽ chỉnh sửa hàm TcpStream::readTcpStream::write để lúc người dùng bấm <CTRL+C> thì dừng việc gửi nhận dữ liệu, xong throw để hàm gọi có thể catch rồi xử lý.

Xem chỗ nào có thể bị đứng rồi sửa chỗ đó :v

Hoặc dùng thread, đơn giản hơn.

Khi người dùng bấm <CTRL+C> thì signal SIGINT sẽ được gửi cho chương trình, mặc định thì chương trình sẽ dừng.
Hiện tại readwrite gọi syscall sendrecv, vì sockfd không ở nonblock mode nên 2 hàm này sẽ block thread hiện tại cho tới khi gửi, nhận xong.

Cách cài:

  • Set nonbocking mode cho TcpStream::sockfd (set trong constructor)
  • Dùng signalfdpoll để chờ 1 trong 2 sự kiện xảy ra: nhận SIGINT hoặc gửi/nhận dữ liệu xong. Rồi xử lý tương ứng.

Cần xem kĩ làm cách nào để dừng việc gửi nhận dữ liệu.

Tài liệu:

Cài active mode

Hiện tại chỉ mới có passive mode :v

Có vài việc cần làm khi cài:

  • Tìm IP address đang dùng để kết nối tới server (để xài trong lệnh PORT)
  • Sửa hàm Ftp::port_or_pasv
  • Sửa hàm Ftp::setup_data_connection. Làm 2 việc song song: đọc reply của server, mở data connection, vì nếu lệnh bị lỗi thì có thể server sẽ không mở kết nối.
  • Thêm hàm Ftp::activeFtp::passive để chọn mode (gán lại bool Ftp::active thôi, không cần gửi nhận gì với server)
  • Sửa hàm list, retrieve, store.

Lúc test active mode nên dùng server trên máy ảo có địa chỉ IP khác máy thật.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.