如何从MFC中的HTTP服务器获取响应?

时间:2016-08-05 03:14:51

标签: c++ sockets mfc

我是学习MFC的学生。 我想从MFC中的HTTP服务器套接字编程中获得响应。 但我无法解决这个问题。

我的代码是:

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
    #pop
    {
        position: absolute;
        top:0;
        left:0;
        width:100%;
        height:100%;
        background-color: rgba(0,0,0,0.5);
        display: none;
    }
    #container
    {
        position: relative;
        width:500px;
        margin:100px auto;
        background-color: white;
        border-radius: 10px;
        padding: 20px;
    }
    #ddown
    {
        width:100px;
    }
</style>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js">
</script>
    <title></title>
</head>
<body>
<select id="ddown" >
    <option></option>
</select>
<div id="pop" >
    <div id="container">
        <h1>Some Check box here</h1>
    </div>
</div>
</body>
<script type="text/javascript">
    $("#ddown").on("click",function(event){
        event.preventDefault();
        $("#pop").show();
    })
    $("#pop").click(function(){
        $("#pop").hide();
    })
</script>
</html>

没有错误,但我收到了NULL。先生帮助我!

1 个答案:

答案 0 :(得分:2)

MFC将Internet会话实现为类func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { var canEdit = selectedCell == indexPath.row ? true : false return canEdit } 的对象。使用此类,您可以创建一个Internet会话或多个同时会话。

以下是一个例子:

CInternetSession

你也可以归结为骨头:

#include <AfxInet.h>
CInternetSession session;

CHttpFile *pHttpFile = NULL;
try
{
    pHttpFile = (CHttpFile *)session.OpenURL(_T("http://www.google.com"));
}
catch (CInternetException)
{
    // Handle exception
}
if(pHttpFile != NULL)
{
    CByteArray data;
    data.SetSize(1024);
    int nBytesRead = pFile->Read(data.GetData(), data.GetSize());
}