Declaration:This project just for learning network programming and use of open source with multi-thread and multi-processing(github).
NOTE:You need Linux to run this Pro.
My blog: http://blog.csdn.net/qq_36196684
Implement of MiniFTP server(Have not finished yet).
FTP(File Transfer Protocal), working in appliction-layer of TCP/IP whose transfer-layer is using TCP.
FTP is based on C/S model.
see more about ftp protocol:https://www.ietf.org/rfc/rfc959.txt
FTP have four file type:
ASCII file
: basic file of FTP
Formed by ASCII chars. Each char have 7bit, and high bit is 0.EBCDIC file
:Image file
: binary file
High bit is 0/1.Local file
:
differece between ASCII file and Binary file:
windows:\r\n Linux:\n mac:\r
- Transfer with
ASCII
:
windows->linux: \r\n->\n
linux->windows: \n->\r\n - Transfer with
Binary
:
Without any change, keeping.
- File struct:
where there is no internal structure and the file is considered to be a continuous sequence of data bytes - record struct: where the file is made up of sequential records
- page struct: where the file is made up of independent indexed pages.
- STREAM Model
The data is transmitted as a stream of bytes. There is no restriction on the representation type used; record structures are allowed. - BLOCK Model
The file is transmitted as a series of data blocks preceded by one or more header bytes.
P1. FTP basic struct model
- active model
client->server - passive model
server->client
P2. The system struct.
In this model, new subprocess will be created when a client requirement is recevied.
Every single c/s connection has two sub process, one is for sevice and another is for
command between service and client processing.
This is the summodel, we implement the function int the model.
P3. summodel
Implement in windows with c++.
NOTE:
reference from http://www.jb51.net/article/96337.htm
Connecting with TCP protocol. Server and client will create a socket by themselves. Server
will wait for connection requirement and decide which client requirement will be accept. Connection
will be made when server and client has suited port and both are free.
Server will continue to wait for connection when client require to break the link, but server only
use the way that one client with one server with out multi-process.
cd ./src
make
sudo ./miniftpd
Then you can connect this server by FTP in Linux.
You can run and test on your localhost, following the next step.
sudo ./miniftpd &
ftp 127.0.0.1