标签:style blog class code c java
有这样的事?
1 #include <event2/event.h> 2 #include <event2/buffer.h> 3 #include <event2/http.h> 4 #include <Winsock2.h> 5 #include <stdlib.h> 6 #include <stdio.h> 7 8 int init_win_socket() 9 { 10 WSADATA wsaData; 11 if(WSAStartup(MAKEWORD(2,2) , &wsaData) != 0) 12 { 13 return -1; 14 } 15 return 0; 16 } 17 18 void generic_handler(struct evhttp_request *req, void *arg) 19 { 20 struct evbuffer *buf = evbuffer_new(); 21 if(!buf) 22 { 23 puts("failed to create response buffer \n"); 24 return; 25 } 26 27 evbuffer_add_printf(buf, "Server Responsed. Requested: %s\n", evhttp_request_get_uri(req)); 28 evhttp_send_reply(req, HTTP_OK, "OK", buf); 29 evbuffer_free(buf); 30 } 31 32 int main(int argc, char* argv[]) 33 { 34 #ifdef WIN32 35 init_win_socket(); 36 #endif 37 38 short http_port = 8081; 39 char *http_addr = "127.0.0.1"; 40 41 struct event_base * base = event_base_new(); 42 43 struct evhttp * http_server = evhttp_new(base); 44 if(!http_server) 45 { 46 return -1; 47 } 48 49 int ret = evhttp_bind_socket(http_server,http_addr,http_port); 50 if(ret!=0) 51 { 52 return -1; 53 } 54 55 evhttp_set_gencb(http_server, generic_handler, NULL); 56 57 printf("http server start OK! \n"); 58 59 event_base_dispatch(base); 60 61 evhttp_free(http_server); 62 63 WSACleanup(); 64 return 0; 65 }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 |
#include <event2/event.h> #include <event2/buffer.h> #include <event2/http.h> #include <Winsock2.h> #include <stdlib.h> #include <stdio.h> int
init_win_socket() { WSADATA wsaData; if (WSAStartup(MAKEWORD(2,2) , &wsaData) != 0) { return
-1; } return
0; } void
generic_handler( struct
evhttp_request *req, void
*arg) { struct
evbuffer *buf = evbuffer_new(); if (!buf) { puts( "failed to create response buffer \n" ); return ; } evbuffer_add_printf(buf, "Server Responsed. Requested: %s\n" , evhttp_request_get_uri(req)); evhttp_send_reply(req, HTTP_OK, "OK" , buf); evbuffer_free(buf); } int
main( int argc, char * argv[]) { #ifdef WIN32 init_win_socket(); #endif short
http_port = 8081; char
*http_addr = "127.0.0.1" ; struct
event_base * base
= event_base_new(); struct
evhttp * http_server = evhttp_new( base ); if (!http_server) { return
-1; } int
ret = evhttp_bind_socket(http_server,http_addr,http_port); if (ret!=0) { return
-1; } evhttp_set_gencb(http_server, generic_handler, NULL); printf( "http server start OK! \n" ); event_base_dispatch( base ); evhttp_free(http_server); WSACleanup(); return
0; } |
的对方水电费德芙巧克力
有这样的事? 的对方水电费德芙巧克力 int i = 0; foreach(i; i<1000; i++){ system.out.println(i); } 还有谁?,布布扣,bubuko.com
有这样的事? 的对方水电费德芙巧克力 int i = 0; foreach(i; i<1000; i++){ system.out.println(i); } 还有谁?
标签:style blog class code c java
原文地址:http://www.cnblogs.com/wgp13x/p/3733594.html