- 博客(24)
- 资源 (4)
- 收藏
- 关注
原创 socket()参数中的地址族、套接字类型、协议号的取值
int socket(int domain, int type, int protocol);1、domain(地址族)和 type(套接字类型)的取值可以见 man socket2、关于 protocol(协议号)的取值可以见 netinet/in.h(可以结合 /etc/protocols看)也可以看这里:socket()--Create Socket, http://publib
2012-09-29 23:47:32 1725
原创 Linux socket-多进程面向连接的服务器客户端程序
总结:1.、TCP的地址复用(address reuse)问题2、HOST_NAME_MAX 的处理方法3、多进程socket编程中 close() 和 shutdown() 的问题4、gethostname() 的问题5、getaddrinfo(hostname, "ruptime", &hint, &ailist) 中 "ruptime" 服务的问题("Servname n
2012-09-28 11:25:02 3327
转载 PHP session的实现原理
PHP SESSION原理我们知道,session是在服务器端保持用户会话数据的一种方法,对应的cookie是在客户端保持用户数据。HTTP协议是一种无状态协议,服务器响应完之后就失去了与浏览器的联系,最早,Netscape将cookie引入浏览器,使得数据可以客户端跨页面交换,那么服务器是如何记住众多用户的会话数据呢?首先要将客户端和服务器端建立一一联系,每个客户端都得有一个
2012-09-27 22:46:35 816
原创 fork()的一些细节
1、哪些段会被复制The child gets a copy of the parent's data space, heap, and stack. Note that this is a copy for the child; the parent and the child do not share these portions of memory. The parent and the
2012-09-26 20:17:09 1609
原创 fork()引起的printf()输出多次的问题
#include #include #include #include int main(){ pid_t pid; printf("before fork - with line break\n"); printf("before fork - no line break"); //fflush(stdout); if( (pid = fork()) < 0 ) {
2012-09-26 12:18:14 3149
原创 CSDN博客搬家到WordPress
CsdnBlogMover(CSDN博客搬家程序)发布http://www.davelv.net/2012/01/03/csdnblogmovercsdn%E5%8D%9A%E5%AE%A2%E6%90%AC%E5%AE%B6%E7%A8%8B%E5%BA%8F%E5%8F%91%E5%B8%83/1、安装BeautifulSoup:http://hi.baidu.com/zc
2012-09-25 02:11:48 3093
原创 WordPress的几款代码高亮插件比较
http://www.oschina.net/news/26092/syntax-highlighter-plugins-for-wordpress1、WP-SynHighlighthttp://wordpress.org/extend/plugins/wp-synhighlight/评价:这是最给力的一款,与其他插件不同的是,它不是通过手动加标签来实现代码板的,而是通过GUI
2012-09-24 23:51:52 20151 2
原创 MySQL 使用基础
1、MySQL新建用户,授权,删除用户,修改密码http://www.cnblogs.com/analyzer/articles/1045072.html2、修改root密码$ mysqladmin -u root -p password Enter password:3、phpMyAdmin 修改数据库登录用户名和密码phpMyAdmin 安装目录下的 c
2012-09-24 20:05:31 817
原创 调用exec()后进程在何处终止
调用exec()后进程在何处终止#include #include #include #include int main(){ int a = 1; int pid; char buff[] = "before fork"; if(write(1, buff, sizeof(buff) - 1) != (sizeof(buff) - 1)) { perror("wr
2012-09-24 10:13:05 1445
原创 getaddrinfo(),gethostbyname(),getnetbyaddr(),getservbyname(),getprotobyname()对比总结
1. gethostbyname()原理:查询 /etc/hosts 等文件及 DNS or NIS 服务器The domain name queries carried out by gethostbyname() and gethostbyaddr() use a combination of any or all of the name server named(8), a b
2012-09-22 21:55:06 2659
原创 操作系统中常见术语
参考:《FreeBSD操作系统设计与实现》(The Design and Implementation of the FreeBSD Operating System)附录-术语表
2012-09-22 09:58:34 1695
原创 关于SIGHUP
1. SIGHUP, http://en.wikipedia.org/wiki/SIGHUPSignals have always been a convenient method of inter-process communication (IPC), but in early implementations there wereno user-definable signals (s
2012-09-21 19:16:02 2792
转载 Linux时间变慢解决方法
情景:系统为CentOS-5.4,硬件时间正确(查看硬件时间的方法见下面),系统时间每隔24小时会慢20分钟左右Linux将时钟分为系统时钟(System Clock)和硬件(Real Time Clock,简称RTC)时钟两种。系统时间是指当前Linux Kernel中的时钟,而硬件时钟则是主板上由电池供电的那个主板硬件时钟,这个时钟可以在BIOS的Standard BIOS Fetur
2012-09-19 21:54:40 9256 1
原创 计算机时钟
《tcp-ip详解卷1:协议》附录B - 计算机时钟http://net.pku.edu.cn/~course/cs201/2004/Assembly/BookShelf/tcp-ip%CF%EA%BD%E2%BE%ED1%A3%BA%D0%AD%D2%E9/032.pdf
2012-09-19 21:41:32 1315
原创 进程内存布局
一个由 C/C++编译的程序占用的内存(memory)分为以下几个部分:1. 程序代码区(.text) - 存放函数体的二进制代码 。2. 文字常量区(.rodata) - 常量字符串就是放在这里的,程序结束后由系统释放(rodata—read only data)。3. 全局区/静态区(static) - 全局变量 和 静态变量的存储是放
2012-09-19 00:31:48 9751
原创 编写守护进程
[1] Clear file creation mask. The file mode creation mask that's inherited could be set to deny certain permissions.If the daemon process is going to create files, it may want to set specific perm
2012-09-16 19:31:29 922
原创 Linux(UNIX) 中一些简称的英文全称
tty - teletypewriterhttp://en.wikipedia.org/wiki/Tty_(Unix)getty - get teletypehttp://en.wikipedia.org/wiki/Getty_(Unix)SIGHUP - signal hang up
2012-09-16 18:06:15 1145
原创 vim只能粘贴50行的问题
在当前用户主目录(~)编辑~/.vimrc(如果不存在,新建这个文件),添加一行:set viminfo='1000,至于为什么要输入输入'1000,这个其实不重要,最主要的是输入http://forum.ubuntu.org.cn/viewtopic.php?f=68&t=93332&view=previous
2012-09-16 16:50:00 4939 1
原创 perror() 和 strerror()
#include /* perror() */#include #include /* strerror() */int main(){ fprintf(stderr, "EACCES: %s\n", strerror(EACCES)); errno = ENOENT; perror("ENOENT"); return 0;}/*$ ./a.outEACCES: Per
2012-09-16 16:02:43 607
原创 进程组、会话、控制终端
process group - 进程组session - 会话controlling terminal - 控制终端#include #include #include #include #include #include #include intmain(){ int i, fd0, fd1, fd2; pid_t pid; struct
2012-09-16 15:17:12 969
原创 避免产生僵尸进程的N种方法(zombie process)
注意:1、如果僵尸进程已经产生,当其父进程终止时,僵尸进程还是会消失。避免产生僵尸进程的5种方法:1、推荐方法:fock twice, 用孙子进程去完成子进程的任务(http://blog.csdn.net/duyiwuer2009/article/details/7948040)2、wait(), 但是会使父进程阻塞3、signal(SIGCHLD,SIG_IGN
2012-09-10 22:28:12 8317 1
原创 init 进程
Init The kernel, once it is loaded, finds init in sbin and executes it.When init starts, it becomes the parent or grandparent of all of the processes that start up automa tically on your Linux s
2012-09-08 12:27:52 715
原创 调用 fork 两次避免僵尸进程
Avoid zombie processes by calling fork twice/* * Avoid zombie processes by calling fork twice. * APUE-2e 程序清单8-5 */#include #include #include #include #include "sig_wait_proc.h"int main(
2012-09-05 20:19:38 5034 2
原创 信号实现等待另一个进程
wait for another process implemented by signal-----sig_wait_proc.h#ifndef _SIG_WAIT_PROC_H#define _SIG_WAIT_PROC_Hextern void init_wait();extern void wait_proc();extern void tell_proc(pid_t
2012-09-05 20:15:10 1834
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人