当前位置:首页 » 编程语言 » c语言访问http
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言访问http

发布时间: 2022-08-06 20:52:23

1. c语言,http报文,post请求,求大神详解

URL要放在POST和HTTP/1.1之间,注意加空格。

URL好像不需要域名部分。

2. 如何用C语言打开网站

参考代码如下:

#include<windows.h>
intmain(void)
{
ShellExecute(NULL,"open","http://www..com",NULL,NULL,SW_MINIMIZE);
return0;
}

例子中是最小化打开的,还可以是最大化SW_MAXIMIZE,隐藏SW_HIDE等。

3. linux下C语言怎么读取http文件内容

http是协议
不是文件
你这个说法就有问题了。
如果你想用C读网页 可以考虑使用socket 不过还是有些麻烦的。

4. C语言如何利用socket进行HTTP访问

你用SOCKET访问HTTP就相当于你编个象IE一样的程序了,所以,工作量大。
有现在的HTTP控件对象,这样工作量小多了。

5. C语言或者C++如何调用一个http接口并得到返回结果

用jni
首先
java

public
class
testhello
{
static
{
system.loadlibrary("testhellos");
}
public
static
native
void
hello(string
msg);
public
native
void
getsysid();
public
native
string
getkeycode(string
sysid);
public
native
boolean
testkeycode(string
sysid,
string
keycode);
public
static
void
main(string[]
args)
{
//
hello("hello,kimm!");
testhello
t=
new
testhello();
t.getsysid();
}
}
用javac
testhello.java,
java
testhello,javah
-classpath
.
-verbose
testhello
。将生产的头文件用到c++
中的
heardfileds
中。然后在
sources
files
中实现
heardfieds
的方法。实现的方法,其实就是你要调用c++的方法、

6. 如何用c语言实现http服务器

//服务端简易代码如下:
#include<stdio.h>
#include<stdlib.h>

#include<err.h>
#include<event.h>
#include<evhttp.h>

voidhttp_handle(structevhttp_request*req,void*arg);/*HTTPRequestHandle*/

intmain(){
structevhttp*httpd;
event_init();
httpd=evhttp_start("0.0.0.0",2345);
if(httpd==NULL){
fprintf(stderr,"Error:Unabletolistenon%s:%d ");
exit(1);
}
evhttp_set_timeout(httpd,2000);
evhttp_set_gencb(httpd,http_handle,NULL);
event_dispatch();
evhttp_free(httpd);

return0;
}

voidhttp_handle(structevhttp_request*req,void*arg){
structevbuffer*buf;
buf=evbuffer_new();

/*Responsetheclient*/
evhttp_send_reply(req,HTTP_OK,"OK",buf);

//evbuffer_add_printf(buf,"%s","HTTPSQS_AUTH_FAILED");

/*Releasethememory*/
evbuffer_free(buf);
fprintf(stderr,"Send ");
}

编译:编译时把libevent的类库中的.so文件和.h文件连接进来。

7. c语言用http协议通讯

connect
write("请求字符串");
。。。
write("请求字符串");