如题,谢谢各位作答

解决方案 »

  1.   

    我现在尝试着用了
    CInternetSession CIS;
    CHttpConnection *http = NULL;
    CHttpFile *file = NULL;
    http = CIS.GetHttpConnection("bt1.54new.com",INTERNET_FLAG_EXISTING_CONNECT,8080);
    file = http->OpenRequest(1,"/announce?info_hash=184894216CF1F674310BEDB6A4BD5AFEC7E391D1&peer_id=0000000000000000000000001B65A5CE893ADDBC&port=5000&uploaded=0&download=0&left=107207984");
    但貌似没用哦,这样可以吗?还是参数有误?
      

  2.   

    我看别人有是这样的:
    GET   /announce?info_hash=1%11%3F%CC%D9%E0%C7%91%D2%B2e%19d%9B%08%2Ba%3F%E6%E2&peer_id=%2DBC0062%2D%16%18%83%7F%CC%DF%C3%DC%A453%C3&port=13506&uploaded=0&downloaded=0&left=0&compact=1&event=started&numwant=50   HTTP/1.1   
      Host:222.208.183.16   
      User-Agent:   BitTorrent/3.4.2   
      Accept:*/*   
      Connection:close这在程序里怎么写?谢谢!
      

  3.   

    这是MSDN 上的讲解:CHttpFile* OpenRequest( LPCTSTR pstrVerb, LPCTSTR pstrObjectName, LPCTSTR pstrReferer = NULL, DWORD dwContext = 1, LPCTSTR* pstrAcceptTypes = NULL, LPCTSTR pstrVersion = NULL, DWORD dwFlags = INTERNET_FLAG_EXISTING_CONNECT );CHttpFile* OpenRequest( int nVerb, LPCTSTR pstrObjectName, LPCTSTR pstrReferer = NULL, DWORD dwContext = 1, LPCTSTR* pstrAcceptTypes = NULL, LPCTSTR pstrVersion = NULL,  DWORD dwFlags = INTERNET_FLAG_EXISTING_CONNECT );Return ValueA pointer to the CHttpFile object requested. ParameterspstrVerbA pointer to a string containing the verb to use in the request. If NULL, "GET" is used.pstrObjectNameA pointer to a string containing the target object of the specified verb. This is generally a filename, an executable module, or a search specifier.pstrRefererA pointer to a string that specifies the address (URL) of the document from which the URL in the request (pstrObjectName) was obtained. If NULL, no HTTP header is specified. dwContextThe context identifier for the OpenRequest operation. See Res for more information about dwContext.pstrAcceptTypesA pointer to a null-terminated string indicating content types accepted by the client. If the string is NULL, the servers interpret that the client only accepts documents of type "text/*" (that is, only text documents and not pictures or other binary files). The content type is equivalent to the CGI variable CONTENT_TYPE, which identifies the type of data for queries that have attached information, such as HTTP POST and PUT.pstrVersionA pointer to a string defining the HTTP version. If NULL, "HTTP/1.0" is used.dwFlagsAny combination of the INTERNET_ FLAG_* flags. See the Res for a description of possible dwFlags values.nVerbA number associated with the HTTP request type. Can be one of the following: HTTP request type nVerb value 
    HTTP_VERB_POST 0 
    HTTP_VERB_GET 1 
    HTTP_VERB_HEAD 2 
    HTTP_VERB_PUT 3 
    HTTP_VERB_LINK 4 
    HTTP_VERB_DELETE 5 
    HTTP_VERB_UNLINK 6 
    ResCall this member function to open an HTTP connection.dwFlags can be one of the following:Internet flag Description 
    INTERNET_FLAG_RELOAD Forces a download of the requested file, object, or directory listing from the origin server, not from the cache.  
    INTERNET_FLAG_DONT_CACHE Does not add the returned entity to the cache.  
    INTERNET_FLAG_MAKE_PERSISTENT Adds the returned entity to the cache as a persistent entity. This means that standard cache cleanup, consistency checking, or garbage collection cannot remove this item from the cache. 
    INTERNET_FLAG_SECURE Uses secure transaction semantics. This translates to using SSL/PCT and is only meaningful in HTTP requests  
    INTERNET_FLAG_NO_AUTO_REDIRECT Used only with HTTP, specifies that redirections should not be automatically handled in CHttpFile::SendRequest.  
    Override the dwContext default to set the context identifier to a value of your choosing. The context identifier is associated with this specific operation of the CHttpConnection object created by its CInternetSession object. The value is returned to CInternetSession::OnStatusCallback to provide status on the operation with which it is identified. See the articleInternet First Steps: WinInet for more information about the context identifier. 
      

  4.   

    这个我看过的,但是file里面什么都没有让我太崩溃了,至少来个错误代码什么的吧
      

  5.   

    http://mfc.365dev.net/CHttpConnection-OpenRequest-6726.html
    这有一个 你看看对你有没有帮助
      

  6.   

    恩,我看了下,我其实是想从指定的服务器返回peers列表,应该不是单纯的返回网页吧,估计那里也没网页额
      

  7.   

    没弄过HTTP的  就弄过FTP 和EMAIL ,不是很懂
      

  8.   

    恩。。没事,我再等等好了,FTP是乍整的?能发段上来么?
      

  9.   

    FTP 是做JAVA课设是  做的
      

  10.   

    你要按照自己的具体情况来写Request的啊,你先人工进行gET,接着用WinsockExpert2先抓个包,然后从其中获得服务器提交的信息。从其中提取出自己需要的东西。
      

  11.   

    直接用SOCKET发送不就可以了嘛??
    sprintf(sendStr, "GET http://%s:%d/CameraID=%d&Type=zyh264  HTTP/1.1\r\n\r\n", m_szIP, m_iPort, m_iCameraID);
    send(sock, sendStr);
      

  12.   

    直接用socket来发送就行了
    HTTP就是基于TCP协议的
    是一个超文本传输的应用层协议
    下面是请求某个文件的一部分数据的HTTP GET请求例子 //  构造请求头 
    CStringA strReqest;
    CStringA strRange;
    strRange.Format("%d-%d",task.nFrom,task.nTo);
    strReqest.Append("GET ");
    strReqest.Append("http://");
    strReqest.Append(m_stHost);
    strReqest.Append(task.strFileURL);
    strReqest.Append(" HTTP/1.1\r\n");
    strReqest.Append("Accept: */*\r\n");
    strReqest.Append("Accept-Language: zh-cn\r\n");
    strReqest.Append("Accept-Encoding: gzip, deflate\r\n");
    strReqest.Append("User-Agent:iSpeeded 1.0.0.1 (Windows)\r\n");
    strReqest.Append("Host: ");
    strReqest.Append(m_stHost);
    strReqest.Append("\r\n");
    strReqest.Append("Range:bytes=");
    strReqest.Append(strRange);
    strReqest.Append("\r\n");
    strReqest.Append("Connection: Keep-Alive\r\n");
    strReqest.Append("Pragma: no-cache\r\n");
    strReqest.Append("Cache-Control: no-cache\r\n\r\n");
    nRet = send(hsocket,strReqest,strReqest.GetLength(),0);