资源简介
它的原理也相当的简单,客户端程序实现一个命令行或图形界面,将用户命令翻译成 FTP 命令,并发送给服务器端程序。服务器端程序响应 FTP 命令,并将操作成功与否的信息以 FTP 响应形式返回给客户端程序。双方遵守 FTP 协议,完成文件传输服务。 就是利用MFC提供的CSocket类和CAsyncsocket类实现一个客户/服务器模式的数据通信模式,使用CSocketFile类和CArchive类来读写数据。它很好的实现了所有的功能,提供了简洁实用的接口。
代码片段和文件信息
/*/////////////////////////////////////////////////////////////////////
FTPclient.cpp (c) GDI 1999
V1.0.0 (10/4/99)
Phil Anderson. philip@gd-ind.com
Simple FTP client functionality. If you have any problems with it
please tell me about them (or better still e-mail me the fixed
code). Please feel free to use this code however you wish although
if you make changes please put your name in the source & comment what
you did.
Nothing awesome going on here at all (all sockets are used in
synchronous blocking mode) but it does the following
things WinInet doesn‘t seem to:
* Supports loads of different firewalls (I think I don‘t
have access to all types so they haven‘t all been fully
tested yet)
* Allows you to execute any command on the FTP server
* Adds 10K to your app install rather than 1Mb #;-)
Functions return TRUE if everything went OK FALSE if there was an
error. A message describing the outcome (normally the one returned
from the server) will be in m_retmsg on return from the function.
There are a few error msgs in the app‘s string table that you‘ll
need to paste into your app along with this file & FTPclient.h
If you created your app without checking the “Use Windows Sockets“
checkbox in AppWizard you‘ll need to add the following bit of code
to you app‘s InitInstance()
if(!AfxSocketInit())
{
AfxMessageBox(“Could not initialize Windows Sockets!“);
return FALSE;
}
To use:
1/ Create an object of CFTPCommandProcessor.
2/ Use LogOnToServer() to connect to the server. Any arguments
not used (e.g. if you‘re not using a firewall) pass an empty
string or zero for numeric args. You must pass a server port
number use the FTP default of 21 if you don‘t know what it is.
3/ Use MoveFile() to upload/download a file 1st arg is local file
path 2nd arg is remote file path 3rd arg is TRUE for a PASV
connection (required by some firewalls) FALSE otherwise 4th arg
is TRUE to upload FALSE to download file. MoveFile only works in
synchronous mode (ie the function will not return ‘till the transfer
is finished). File transfers are always of type BINARY.
4/ You can use FTPcommand() to execute FTP commands (eg
FTPcommand(“CWD /home/mydir“) to change directory on the server)
note that this function will return FALSE unless the server response
is a 200 series code. This should work fine for most FTP commands
otherwise you can use WriteStr() and ReadStr() to send commands &
interpret the response yourself. Use LogOffServer() to disconnect
when done.
/////////////////////////////////////////////////////////////////////*/
#include “stdafx.h“
#include “MyFTPClient.h“
#include “FTPCommandProcessor.h“
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 155726 2009-06-05 14:33 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\Debug\FTPSOCKET.exe
文件 13850 2003-09-27 04:32 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\FTPCommandProcessor.cpp
文件 1319 2003-09-27 02:46 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\FTPCommandProcessor.h
文件 22572 2003-09-30 20:13 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\FTPSOCKET.APS
文件 1746 2003-10-19 16:43 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\FTPSOCKET.clw
文件 4500 2003-09-27 04:39 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\FTPSOCKET.dsp
文件 543 2002-08-06 13:24 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\FTPSOCKET.dsw
文件 173056 2003-10-19 16:43 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\FTPSOCKET.ncb
文件 82944 2009-06-09 21:13 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\FTPSOCKET.opt
文件 758 2003-09-30 20:13 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\FTPSOCKET.plg
文件 6911 2003-09-27 03:38 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\FTPSOCKET.rc
文件 1614 2002-08-07 18:02 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\ListItem.cpp
文件 691 2002-03-19 16:53 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\ListItem.h
文件 2205 2003-09-27 03:16 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\MyFTPClient.cpp
文件 1357 2002-08-06 13:24 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\MyFTPClient.h
文件 18438 2003-09-27 03:37 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\MyFTPClientDlg.cpp
文件 3598 2003-09-27 03:19 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\MyFTPClientDlg.h
文件 3633 2002-08-06 13:24 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\ReadMe.txt
文件 1078 2002-08-06 13:24 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\res\FTPSOCKET.ico
文件 401 2002-08-06 13:24 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\res\FTPSOCKET.rc2
文件 1462 2002-08-08 20:58 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\Resource.h
文件 211 2003-09-27 02:53 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\StdAfx.cpp
文件 1108 2002-08-06 19:04 用Socket编程实现FTP\用Sochets实现 FTP\ftp客户端\StdAfx.h
文件 1190 2003-09-29 13:33 用Socket编程实现FTP\用Sochets实现 FTP\MyFtpServer\MyFtpServer\AccountDialog.cpp
文件 1261 2003-09-29 13:33 用Socket编程实现FTP\用Sochets实现 FTP\MyFtpServer\MyFtpServer\AccountDialog.h
文件 147550 2009-06-05 14:33 用Socket编程实现FTP\用Sochets实现 FTP\MyFtpServer\MyFtpServer\Debug\MyFtpServer.exe
文件 37604 2003-09-29 15:06 用Socket编程实现FTP\用Sochets实现 FTP\MyFtpServer\MyFtpServer\MyFtpServer.aps
文件 2421 2003-09-29 21:45 用Socket编程实现FTP\用Sochets实现 FTP\MyFtpServer\MyFtpServer\MyFtpServer.clw
文件 2133 2003-09-27 05:04 用Socket编程实现FTP\用Sochets实现 FTP\MyFtpServer\MyFtpServer\MyFtpServer.cpp
文件 4547 2003-09-29 16:52 用Socket编程实现FTP\用Sochets实现 FTP\MyFtpServer\MyFtpServer\MyFtpServer.dsp
............此处省略29个文件信息
- 上一篇:h225协议 RAS信令
- 下一篇:学生信息管理系统源码
相关资源
- websocket实现一对一聊天
- 代码客:G-TcpServer(IOCP) 1.0 正式版及
- SOCKET 网络编程 计算机网络 作业 客户
- linux 网络实验 ftp程序
- 用Socket写的简易FTP服务器和客户端
- socket小工具(可方便建立TCP UDP的soc
- socket客户端源码
- 基于CSocket的多人聊天室
- socket文件传输源码
- Socket自制系统
- HP用SOCKET实现(客户端---服务端)
- zeromq的windows版本安装包
- STM32分别以串口硬件SPI模拟并口驱动
- 《TCP/IP:协议分析与应用编程》课后
- linux下基于socket和curses的双人弹球游戏
- 计算机网络socket编程实验
- linux下socket can 编程详解
- FANUC机器人Socket Message通讯设置及使用
- Delphi简单实现局域网远程开机
- 易语言websocket服务器源码
- websocket规范 RFC6455 中文版
- 富士康H61S主板最新BIOS,支持22NCPU
- Socket-UDP整合消息接收,发送
- websocket-rtsp-proxy-test.zip
- 基于QTsocket的局域网聊天室
- SuperSocket服务端与客户端通信
- 网络编程socket文件图片等传送
- tomcat7.0.42 下部署websocket需要替换的包
- 安卓手机socket通信服务端和客户端
- 物联网,WEBSOCKET丰富案例
评论
共有 条评论