Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 使用wininet连接到Internet_C_Wininet_Getlasterror - Fatal编程技术网

C 使用wininet连接到Internet

C 使用wininet连接到Internet,c,wininet,getlasterror,C,Wininet,Getlasterror,我已经使用Python的SimpleHTTPServer在我的笔记本电脑上设置了一个127.0.0.1:8000的临时服务器。我写了一个小C程序,试图连接到服务器 然后看看那里的一个文件,d.txt。但是,我的程序没有正确连接HttpSendRequestA抛出ERROR\u SXS\u KEY\u NOT\u FOUND(00002EE7)但问题更严重 #include <stdio.h> #include <stdlib.h> #include <unistd.

我已经使用Python的SimpleHTTPServer在我的笔记本电脑上设置了一个127.0.0.1:8000的临时服务器。我写了一个小C程序,试图连接到服务器 然后看看那里的一个文件,
d.txt
。但是,我的程序没有正确连接
HttpSendRequestA
抛出
ERROR\u SXS\u KEY\u NOT\u FOUND(00002EE7)
但问题更严重

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <wininet.h>

int main(void) {

  HINTERNET* openHandle;
  openHandle = InternetOpenA("Windows+NT+5.1",0, NULL, NULL, 0);

  HINTERNET* connectHandle;
  connectHandle = InternetConnectA(openHandle,"127.0.0.1",8000,NULL,NULL,0,3,0);

  HINTERNET* httpHandle;
  char* arr[] = {"text//*", NULL};
  httpHandle = HttpOpenRequestA(connectHandle, "GET", "d.txt", "HTTP/1.1", 0,
               arr,0,0);

  int result2;
  result2 = HttpSendRequestA(httpHandle, 0,0,0,0);
  printf("%d",result2);

  return EXIT_SUCCESS;
}
#包括
#包括
#包括
#包括
#包括
内部主(空){
HINTERNET*openHandle;
openHandle=InternetOpenA(“Windows+NT+5.1”,0,空,空,0);
腹地*连接手柄;
connectHandle=InternetConnectA(openHandle,“127.0.0.1”,8000,NULL,NULL,0,3,0);
HINTERNET*httpHandle;
char*arr[]={“text/*”,NULL};
httpHandle=HttpOpenRequestA(connectHandle,“GET”,“d.txt”,“HTTP/1.1”,0,
arr,0,0);
结果2;
结果2=HttpSendRequestA(httpHandle,0,0,0);
printf(“%d”,结果2);
返回退出成功;
}