小弟我什么小弟我的ftp服务器连接不上啊但是实际上这个ftp是可以连接的
我什么我的ftp服务器连接不上啊,但是实际上这个ftp是可以连接的
#include <iostream>
#include <winsock2.h>
#include <Wininet.h>
#pragma comment(lib, "Ws2_32.lib ")
#pragma comment(lib, "Wininet.lib ")
using namespace std;
bool InitSock();
int main()
{
InitSock();
HINTERNET hInet=::InternetOpen( "Testing ",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
if (hInet==NULL)
{ cout < < "Internet open failed! " < <endl;
return -1;
}
if(InternetConnect(hInet, "202.118.250.23 ",INTERNET_DEFAULT_FTP_PORT,
NULL,NULL,INTERNET_SERVICE_FTP,0,NULL))
{
cout < < "连接服务器失败 " < <endl;
}
system( "pause ");
return 0;
}
bool InitSock()
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
return false;
}
if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 )
{
WSACleanup();
return true ;
}
return true;
}
------解决方案--------------------
wVersionRequested = MAKEWORD( 2, 2 );
把版本降低一下试试
#include <iostream>
#include <winsock2.h>
#include <Wininet.h>
#pragma comment(lib, "Ws2_32.lib ")
#pragma comment(lib, "Wininet.lib ")
using namespace std;
bool InitSock();
int main()
{
InitSock();
HINTERNET hInet=::InternetOpen( "Testing ",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
if (hInet==NULL)
{ cout < < "Internet open failed! " < <endl;
return -1;
}
if(InternetConnect(hInet, "202.118.250.23 ",INTERNET_DEFAULT_FTP_PORT,
NULL,NULL,INTERNET_SERVICE_FTP,0,NULL))
{
cout < < "连接服务器失败 " < <endl;
}
system( "pause ");
return 0;
}
bool InitSock()
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
return false;
}
if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 )
{
WSACleanup();
return true ;
}
return true;
}
------解决方案--------------------
wVersionRequested = MAKEWORD( 2, 2 );
把版本降低一下试试