Background: I have recently made a project. I need to be a ftp client. So I found a lot of source code. I didn't have particularly satisfied. So I plan to write one.
Tell the content to build a main thread mode of FTP. I will not repeat it for the FTP protocol itself. The most important thing is the model of the design.
Establish a connected Socket class:
The first is to establish a BaseSocket abstraction class. This is also the case in accordance with the principle of mode design. Because there is a command socket connection in the FTP protocol. A data socket connection. You need to put two different socket feature abstraction. Accept () method Used in active mode Method BIND () Method for Data Link Socket Bind () Method Connecting the Local Node Connect () Connecting the server method GetStream method Get the network transport stream setSocketoption method Set the features of the socket. You need to use Listen to listen to Socket in active mode.