- 浏览: 1475143 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (691)
- linux (207)
- shell (33)
- java (42)
- 其他 (22)
- javascript (33)
- cloud (16)
- python (33)
- c (48)
- sql (12)
- 工具 (6)
- 缓存 (16)
- ubuntu (7)
- perl (3)
- lua (2)
- 超级有用 (2)
- 服务器 (2)
- mac (22)
- nginx (34)
- php (2)
- 内核 (2)
- gdb (13)
- ICTCLAS (2)
- mac android (0)
- unix (1)
- android (1)
- vim (1)
- epoll (1)
- ios (21)
- mysql (3)
- systemtap (1)
- 算法 (2)
- 汇编 (2)
- arm (3)
- 我的数据结构 (8)
- websocket (12)
- hadoop (5)
- thrift (2)
- hbase (1)
- graphviz (1)
- redis (1)
- raspberry (2)
- qemu (31)
- opencv (4)
- socket (1)
- opengl (1)
- ibeacons (1)
- emacs (6)
- openstack (24)
- docker (1)
- webrtc (11)
- angularjs (2)
- neutron (23)
- jslinux (18)
- 网络 (13)
- tap (9)
- tensorflow (8)
- nlu (4)
- asm.js (5)
- sip (3)
- xl2tp (5)
- conda (1)
- emscripten (6)
- ffmpeg (10)
- srt (1)
- wasm (5)
- bert (3)
- kaldi (4)
- 知识图谱 (1)
最新评论
-
wahahachuang8:
我喜欢代码简洁易读,服务稳定的推送服务,前段时间研究了一下go ...
websocket的helloworld -
q114687576:
http://www.blue-zero.com/WebSoc ...
websocket的helloworld -
zhaoyanzimm:
感谢您的分享,给我提供了很大的帮助,在使用过程中发现了一个问题 ...
nginx的helloworld模块的helloworld -
haoningabc:
leebyte 写道太NB了,期待早日用上Killinux!么 ...
qemu+emacs+gdb调试内核 -
leebyte:
太NB了,期待早日用上Killinux!
qemu+emacs+gdb调试内核
代码是《linux高级程序设计》第5章的内容
betterserver.c
len=recv(fd,buf,13,0);指定了缓冲
liburl使用
yum install libcurl-devel
这个是依赖
gcc -I /usr/local/include/ -o getweb liburl.c -lcurl
mqq@208_181:~/fabricehao/test/20120726> cat errtcpserver.c #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> int main(int args,char * argv){ int i,s,fd,len; struct sockaddr_in my_addr; struct sockaddr_in remote_addr; int sin_size; char buf[BUFSIZ]; memset(&my_addr,0,sizeof(my_addr)); my_addr.sin_family=AF_INET; my_addr.sin_addr.s_addr=INADDR_ANY; unsigned int pp=87654; my_addr.sin_port=htons(pp); if((s=socket(AF_INET,SOCK_STREAM,0))<0){ perror("socket"); return 1; } if(bind(s,(struct sockaddr *)&my_addr,sizeof(struct sockaddr))<0){ perror("bind"); return 1; } listen(s,5); sin_size=sizeof(struct sockaddr_in); if((fd=accept(s,(struct sockaddr *)&remote_addr,&sin_size))<0) { perror("accept"); return 1; } printf("accept client %s\n",inet_ntoa(remote_addr.sin_addr)); len=send(fd,"welcome to my server\n",21,0); for(i=0;i<5;i++){ len=recv(fd,buf,BUFSIZ,0); buf[len]='\0'; printf("%s\n",buf); } close(fd); close(s); return 0; }
mqq@208_181:~/fabricehao/test/20120726> cat badclient.c #include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int main(args,argv){ int i,s,fd,len; struct sockaddr_in remote_addr; int sin_size; char buf[BUFSIZ]; memset(&remote_addr,0,sizeof(remote_addr)); remote_addr.sin_family=AF_INET; remote_addr.sin_addr.s_addr=inet_addr("127.0.0.1"); unsigned int pp=87654; remote_addr.sin_port=htons(pp); if((s=socket(AF_INET,SOCK_STREAM,0))<0){ perror("socket"); return 1; } if(connect(s,(struct sockaddr *)&remote_addr,sizeof(struct sockaddr))<0){ perror("connect"); return 1; } printf("connect to server"); len=recv(s,buf,BUFSIZ,0); buf[len]='\0'; printf("%s",buf); len=send(s,"test1 message",13,0); len=send(s,"test2 message",13,0); len=send(s,"test3 message",13,0); len=send(s,"test4 message",13,0); len=send(s,"test5 message",13,0); close(s); return 0; }
betterserver.c
len=recv(fd,buf,13,0);指定了缓冲
#include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> int main(int args,char * argv){ int i,s,fd,len; struct sockaddr_in my_addr; struct sockaddr_in remote_addr; int sin_size; char buf[BUFSIZ]; memset(&my_addr,0,sizeof(my_addr)); my_addr.sin_family=AF_INET; my_addr.sin_addr.s_addr=INADDR_ANY; unsigned int pp=87654; my_addr.sin_port=htons(pp); if((s=socket(AF_INET,SOCK_STREAM,0))<0){ perror("socket"); return 1; } if(bind(s,(struct sockaddr *)&my_addr,sizeof(struct sockaddr))<0){ perror("bind"); return 1; } listen(s,5); sin_size=sizeof(struct sockaddr_in); if((fd=accept(s,(struct sockaddr *)&remote_addr,&sin_size))<0) { perror("accept"); return 1; } printf("accept client %s\n",inet_ntoa(remote_addr.sin_addr)); len=send(fd,"welcome to my server\n",21,0); for(i=0;i<5;i++){ len=recv(fd,buf,13,0); buf[len]='\0'; printf("%s\n",buf); } close(fd); close(s); return 0; }
liburl使用
mqq@208_181:~/fabricehao/test/20120726> cat liburl.c #include <stdio.h> #include <curl/curl.h> int main(int args,char * argv){ CURL * curl; CURLcode res; curl =curl_easy_init(); if(!curl) { perror("curl"); return 1; } curl_easy_setopt(curl,CURLOPT_URL,argv[1]); curl_easy_setopt(curl,CURLOPT_PROXY,"webproxy:8080"); res=curl_easy_perform(curl); curl_easy_cleanup(curl); return 0; }
yum install libcurl-devel
这个是依赖
gcc -I /usr/local/include/ -o getweb liburl.c -lcurl
发表评论
-
xl2tp 备份
2019-09-24 16:25 6792019年9月24日更新: 注意,需要开启firewall ... -
sdl笔记
2019-01-31 17:19 732sdl教程教程 https://github.com/Twin ... -
tinyemu
2019-01-24 17:59 1431参考https://bellard.org/jslinux/t ... -
aws搭建xl2tp给iphone使用
2018-12-26 21:37 18872019年12月26日 可以参考原来的配置 https:// ... -
consul的基本使用
2017-06-27 11:13 1398### 安装 [centos7上consul的安装](ht ... -
lvs的helloworld
2017-06-13 20:36 596###################lvs######### ... -
系统调用的helloworld
2017-05-04 16:14 630《2.6内核标准教程》 p293 #include < ... -
bitcoin和cgminer的安装
2017-04-05 22:45 1956参考 http://blog.csdn.net/rion_ch ... -
ceph安装和常用命令
2017-03-21 21:55 952/etc/hosts ssh-keygen ssh-copy- ... -
mobile terminal 笔记
2016-12-02 15:35 621找出旧的iphone4 越狱之后可以变个小操作系统 mobi ... -
socket基础和select(python)
2016-06-14 17:21 1797上接 c语言的socket基础ht ... -
socket基础(c语言)
2016-06-14 16:45 992不使用select 普通的基础socket连接,对多个客户端的 ... -
ffmpeg+nginx 的直播(2,直播摄像头和麦克风)
2016-05-28 20:21 4354假设我的服务器是centos7 192.168.139.117 ... -
ffmpeg+nginx 的直播(1,直播播放的视频文件)
2016-05-26 17:11 659064位操作系统centos7 ############ 1.一 ... -
socat和netcat(nc)
2016-04-29 22:36 1742转 原文链接: http://www.wenquan.name ... -
neutron基础九(qemu nat网络)
2016-02-06 17:21 1618接上基础八,kvm透传nested忽略 1.在主机ce ... -
neutron基础八(qemu 桥接网络)
2016-02-06 13:13 1542qemu的桥接和nat的qemu启动命令是一样的,但是后续的脚 ... -
neutron基础七(qemu tap)
2016-02-02 17:02 1028使用qemu 建立个虚拟机 然后用tap设备, 根据基础六,t ... -
neutron基础六(bridge fdb)
2016-01-28 18:30 2259转发表 在三台机器上建立三个namespace 192.16 ... -
南北流量
2016-01-23 23:26 1819一、三层网络架构: 接入层:负责服务器的接入和隔离 汇聚层:汇 ...
相关推荐
*) Fix: If remote host shut down socket(Socket.ShutDown), the empty command buffer considered as bad empty command (not disposing session before socket close reach). (04.10.2011) *) New: Added ...
最近在linux上装Aphace... can't connect to local MySQL server through socket 'var/run/mysqld/mysqld.sock' 这个把我弄得几近崩溃,我在网上查找了很多的解决办法,大概有几种解决方案: 1.权限问题 2.修改/
3、Can’t connect to local MySQL server through socket ‘/Data/mydata/mysql.sock’ socket文件目录不对应导致的问题 4、今天要说的就是 没有打开only_full_group_by Cause:...
- **4.1.20** `UPNP_E_SOCKET_CONNECT [-204]`: Indicates a connection error on a socket. - **4.1.21** `UPNP_E_OUTOF_SOCKET [-205]`: Signals that there are no more available sockets. - **4.1.22** `UPNP_E...
case E_BAD_SOCK_FD : default : unknown error! 6 bugs both side couldn't send control signal to each other, that is you can only send message that after a line break. so there are ...
”server is ok”:”server is bad”}END{print health}’ server is ok 说白了这些方式都是封装了curl库的,另外还有一些关于http的模块,例如perl的LWP,python的httplib,urllib或者urllib2 也可以去实现,今天就...
- **400 Bad Request**:客户端请求语法错误。 - **404 Not Found**:请求的资源未找到。 - **500 Internal Server Error**:服务器遇到了无法处理的情况。 - **501 Method Not Implemented**:服务器不支持请求中...
BadStudent badStudent = new BadStudent("Bob", 22, "Male"); badStudent.eat(); badStudent.smoke(); badStudent.drink(); } } ``` #### 5. 多态及向下转型 **知识点**: 多态性,父类引用指向子类对象,以及...
- `socket address`:指明Samba监听的IP地址。 - `security`:设置共享安全级别,包括`share`(无验证)、`user`(用户级验证)、`server`(服务器级验证)和`domain`(域级验证)。 - `password server`:当使用...
2. Error -10057: "Failed to transmit data to network: socket is not connected." 这个错误可能是由于网络连接问题。如果在多台机器上执行相同测试,只有部分机器出现错误,可能是特定机器的网络状况问题。检查...
cvs [pserver aborted]: bad auth protocol start: hi Connection closed by foreign host. ``` 这表明CVS服务已经正确启动并且响应客户端请求。 #### 四、配置客户端 ##### 4.1 Wincvs (WinCvs2_0_8) 对于...
2. **代理服务器(Proxy Server)**:一种服务器(或服务程序),作为客户端和服务端之间的中间层,可以过滤、缓存或修改请求和响应数据。 3. **Java网络编程**:利用Java语言进行网络应用开发的技术。 4. **HTTP...
interesting side-effects depending on your application and web server. ; You may be able to send headers and cookies after you've already sent output ; through print or echo. You also may see ...
issue with potential bad data in a database used by DLZ or SDB. [RT #34993] Fix build issue on newer FreeBSD needing -lhx509 for GSSAPI build. [RT #35001] Address read after free in server side...
如果在安装过程中遇到错误提示“/usr/bin/perl: bad interpreter: No such file or directory”,可以通过`yum -y install perl perl-devel`来安装Perl及其开发库。如果遇到“error while loading shared libraries:...
- 注意:首次启动可能会出现关于`bad crc`的警告信息。这通常是由于环境变量尚未保存导致的。一旦保存了环境变量设置,这种警告就会消失。 #### 三、配置TFTP服务器 为了便于从主机向开发板传输文件,需要配置...
1. **[global]**:全局配置段,包含服务器的一般设置,如工作组名(workgroup = MYGROUP),服务器的角色(server string = %h server (Samba, Ubuntu)),以及安全级别(security = user)。 2. **[homes]**:此...
Minor bugs fixed (some variants of boundary)14/10/971.1.0- Warning: WSockets1.2 have some bugs that result in bad attachments. So I decided to use the sockets of Delphi 3 founded in D3 c/s D3.01 pro ...
local http_server = require 'socket.http.server' local function handle(ws) while true do local msg, err = ws:receive() if not msg then break end print('Received:', msg) ws:send(msg) -- echo back...