當前位置:首頁 » 編程語言 » 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("請求字元串");