91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3.13MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2023-10-15
  • 語言: C/C++
  • 標簽: FTP??客戶端??winsock??

資源簡介

這個課程設計是基于winsock接口并且使用C++語言編寫實現FTP客戶端,包含論文,直接在VC6.0++就可以打開。

資源截圖

代碼片段和文件信息

#include?“Winsock.h“
#include?“windows.h“
#include?“stdio.h“
#include?“time.h“
#include?
#define?RECV_PORT?2000
#pragma???comment(lib?“wsock32.lib“)
SOCKET?sock;
char?filename[20];??????//傳送文件名
sockaddr_in?ServerAddr;
char?rbuff[1024];???????//接收緩沖
char?sbuff[1024];???????//發送緩沖
char?IP[20];????????????//目的ip?

//處理help命令
void?help()
{?
?cout<<“#################菜單幫助(輸入以下命令)###############“<??<<“????或者‘help‘...........顯示你提供的所有命令???????“<??<<“???dir...................顯示當前目錄的文件?????“<??<<“???cd....................改變當前目錄和路徑?????“<??<<“???down...................下載(接受)文件???????????“<??<<“???up..................上傳(發送)文件???????????“<??<<“???exit...................退出????????????????????“<??<<“#############################################################“<}

//處理dir命令
void?list(SOCKET?sockfd)
{
?int?nRead;
?while(true)
?{
??nRead=recv(sockrbuff10240);
??if(nRead==SOCKET_ERROR)
??{
???printf(“read?response?error!\n“);
???exit(1);
??}
??if(nRead==0)//數據讀取結束
???break;
??//顯示數據
??rbuff[nRead]=‘\0‘;
??printf(“%s“rbuff);
?}
?
}


int?SendFile(SOCKET?socksendFILE*?file)
{
?printf(“sending?file?data..“);

?for(;;)
?//從文件中循環讀取數據并發送客戶端
?{
??int?r=fread(sbuff11024file);
??if(send(socksendsbuffr0)==SOCKET_ERROR)
??{
???printf(“lost?the?connection?to?client!\n“);
???closesocket(socksend);
???return?0;
??}
??if(r<1024)//文件傳送結束
???break;
?}
?closesocket(socksend);
?printf(“done\n“);
?return?1;
}

//初始化scoket

DWORD?StartSock()
{WSADATA?WSAData;
char?a[20];
memset(a020);
if(WSAStartup(MAKEWORD(22)&WSAData)!=0)
{printf(“sock?init?fail!\n“);
return?(-1);
}
if(strncmp(IPa20)==0){
printf(“請輸入服務器IP:“);
scanf(“%s“&IP);}

ServerAddr.sin_family=AF_INET;
ServerAddr.sin_addr.s_addr=inet_addr(IP);
ServerAddr.sin_port=htons(RECV_PORT);
return(1);
}


//創建套接字

DWORD?CreateSocket()
{
sock=socket(AF_INETSOCK_STREAM0);
if(sock==SOCKET_ERROR)
{printf(“sock?create?fail!?\n“);
WSACleanup();
return(-1);
}
return(1);
}

//發送連接請求

DWORD?CallServer()???{
CreateSocket();
if?(connect(sock(struct?sockaddr?*)&ServerAddrsizeof(ServerAddr))==SOCKET_ERROR)
{
printf(“Connect?fail?\n“);
memset(IP020);
return(-1);
}
return(1);
}

??//發送命令

DWORD?TCPSend(char?data[])??????{
int?length;
length=send(sockdatastrlen(data)0);
if(length<=0)
{
printf(“send?data?error?!?\n“);
closesocket(sock);
WSACleanup();
return(-1);
}
return(1);
}

//主程序

int?main()
{char?order1[10];???????????????//一級指令
?char?order2[20];???????????????//二級指令
?char?order[30];????????????????//指令
?order[0]=‘\0‘;
char?buff[80];??????????//?發送緩沖
FILE?*fd;???????????????????//發送文件
FILE?*fd2;??????????????????//?接收文件
int?count;??????????????????//接收文件計數

int?sin_size=sizeof(ServerAddr);

StartSock();
if(CallServer()==-1) return?main();
printf(“connect?ok!?\n“);
?
pri

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件?????858112??2012-03-10?00:30??0900370205龍海娟\課設說明文檔.doc

?????文件?????135278??2012-03-06?22:07??0900370205龍海娟\源程序\ftp服務端\abc.txt

?????文件???????5002??2011-01-15?14:34??0900370205龍海娟\源程序\ftp服務端\server.cpp

?????文件???????3401??2012-03-09?22:44??0900370205龍海娟\源程序\ftp服務端\server.dsp

?????文件????????520??2012-03-09?22:44??0900370205龍海娟\源程序\ftp服務端\server.dsw

?????文件??????50176??2012-03-09?23:57??0900370205龍海娟\源程序\ftp服務端\server.ncb

?????文件??????48640??2012-03-09?23:57??0900370205龍海娟\源程序\ftp服務端\server.opt

?????文件????????748??2012-03-09?22:44??0900370205龍海娟\源程序\ftp服務端\server.plg

?????文件??????29476??2011-01-15?10:02??0900370205龍海娟\源程序\ftp服務端\Debug\client.obj

?????文件?????184449??2012-03-09?22:44??0900370205龍海娟\源程序\ftp服務端\Debug\server.exe

?????文件?????208008??2012-03-09?22:44??0900370205龍海娟\源程序\ftp服務端\Debug\server.ilk

?????文件??????25571??2012-03-09?22:44??0900370205龍海娟\源程序\ftp服務端\Debug\server.obj

?????文件????3568124??2012-03-09?22:44??0900370205龍海娟\源程序\ftp服務端\Debug\server.pch

?????文件?????476160??2012-03-09?22:44??0900370205龍海娟\源程序\ftp服務端\Debug\server.pdb

?????文件?????230400??2012-03-09?23:57??0900370205龍海娟\源程序\ftp服務端\Debug\vc60.idb

?????文件??????86016??2012-03-09?22:44??0900370205龍海娟\源程序\ftp服務端\Debug\vc60.pdb

?????目錄??????????0??2012-03-10?00:35??0900370205龍海娟\源程序\ftp服務端\Debug

?????目錄??????????0??2012-03-10?00:35??0900370205龍海娟\源程序\ftp服務端

?????文件?????142661??2012-03-09?22:48??0900370205龍海娟\源程序\ftp客戶端\2.jpg

?????文件???????4841??2012-03-09?21:40??0900370205龍海娟\源程序\ftp客戶端\client.cpp

?????文件???????3401??2011-01-15?19:09??0900370205龍海娟\源程序\ftp客戶端\client.dsp

?????文件????????518??2011-01-15?19:09??0900370205龍海娟\源程序\ftp客戶端\client.dsw

?????文件??????50176??2012-03-10?00:30??0900370205龍海娟\源程序\ftp客戶端\client.ncb

?????文件??????48640??2012-03-10?00:30??0900370205龍海娟\源程序\ftp客戶端\client.opt

?????文件???????1201??2012-03-09?22:32??0900370205龍海娟\源程序\ftp客戶端\client.plg

?????文件?????225401??2012-03-09?22:32??0900370205龍海娟\源程序\ftp客戶端\Debug\client.exe

?????文件?????266392??2012-03-09?22:32??0900370205龍海娟\源程序\ftp客戶端\Debug\client.ilk

?????文件??????29704??2012-03-09?22:32??0900370205龍海娟\源程序\ftp客戶端\Debug\client.obj

?????文件????3633436??2012-03-09?22:32??0900370205龍海娟\源程序\ftp客戶端\Debug\client.pch

?????文件?????574464??2012-03-09?22:32??0900370205龍海娟\源程序\ftp客戶端\Debug\client.pdb

............此處省略9個文件信息

評論

共有 條評論