#include "VxWorks.h"
#include "stdio.h"
#include "errnoLib.h"
#include "ftpLib.h"
#include "ioLib.h"
#define HOST "192.168.20.115"
#define USER "vxworks"
#define PWD "vxworks"
#define W_DIR "C:/TEMP"
#define RD_CMD "RETR %s" /*get file from ftp server*/
#define FILE "baoqunmin.txt"
void ftpopen()
{
int ctrlSock;
int dataSock;
char buf[6];
int nBytes;
if(ERROR == ftpXfer(HOST, USER, PWD, "", RD_CMD, W_DIR, FILE, &ctrlSock, &dataSock))
{
printf("\r\n ftp connected failed!");
return ;
}
while((nBytes = read(dataSock, buf, sizeof(buf))) > 0)
{
printf("\r\n it is [%s]", buf);
}
close(dataSock);
if(ERROR == nBytes)
printf("\r\nit is reading error.");
if(ftpCommand(ctrlSock, "QUIT", 0, 0, 0, 0, 0, 0) == FTP_COMPLETE)
printf("\r\nftp is completed");
close(ctrlSock);
}
阅读(1107) | 评论(0) | 转发(0) |