套接字(socket)是一种为计算机网络通信编程的接口,首次出现在美国加州Berkeley大学开发的BSD版本的系统中.有了套接字(应用层),从而允许我们进行服务器/客户端的开发,不必关心底层的细节.详细的关于内核网络协议的实现,我会在以后详细阐述,现在,这篇文章
#include<sys/types.h>
#include<sys/socket.h>
int socket(int domain,int type, int protocol)
` domain`: 代表套接字地址族,常用的有AF_INET,PF_INET(IPv4),AF_INET6(IPv6), AF_IPX(Novell 网络协议)…
type
: 最常用的是SOCK_STREAM和SOCK_DGRAM,分别表示流式套接字和数据包套接字.
protocol
: 一般情况下会设置为0,表示由系统在当前的domain下选择合适的协议.
TODO
#1
首先是APUE,patch和little,加油
#2
在本网站的首页为什么会遇到这样的问题呢,多显示了三个日期,然而,本地测试一点问题没有的
这个用于给出内核启动的命令行,它和用于进程的cmdline项非常像
yubo@debian:/proc$ cat cmdline BOOT_IMAGE=/vmlinuz-3.2.0-4-686-pae root=UUID=84caed03-f243-4a09-afa5-15be502cbfb9 ro quiet yubo@debian:/proc$
这个文件提供了有关系统cpu的多种信息,格式为:文件由多行构成,每行包括一个域名称,一个冒号和一个值
# 在主目录下写成一个名为 .my.cnf的文件,将下面的内容填入其中
[mysql]
user=user
password=pass
[mysqladmin]
user=user
password=pass
在github上每次push要求输入密码和用户名着实烦恼,那么,怎么样可以不用这样呢
以前我好像是用的ssh的方法,需要密钥,现在明白了github的网站推荐使用https,
所以,暂时以https为主,其他的以后慢慢琢磨.可以在_本地主目录_新建.netrc
输入以
下内容:
machine github.com
login <user>
password <password>
真不容易,搞了很久才搞定。首先,你先设定HOME的环境变量,最好全局的,然后把
_netrc
文件放到你设定的HOME文件夹里,然后再克隆下来就方便了。
这个先不讨论了。
所有的git使用的话必须首先fetch origin
,再开发,否则很容易产生冲突
git config –global core.editor vim
因为有些时候新安装的git默认使用的系统语言,导致不方便,所以,有必要修改默认
编辑系统配置文件 .profile
的语言。
alias git='LANG=en_US git'
并source .profile
一下就可以了。
如果让git能够自己补全命令的话,效率非常的高
方法是将git源代码目录中git/contrib/completion/git-completion.bash
这个文件放到用户主目录下。然后使用source .git-completion.bash
即可。
我把配置文件放在了github
```c /************************* references: http://derekmolloy.ie/writing-a-linux-kernel-module-part-2-a-character-device/ ************************/ #include<linux/mutex.h> #include<linux/err.h> #include<linux/init.h> #include<linux/module.h> #include<linux/device.h> #include<linux/kernel.h> #include<linux/fs.h> #include<asm/uaccess.h> #define DEVICE_NAME “yubochar” #define CLASS_NAME “yubo-c”
MODULE_LICENSE(“GPL”); MODULE_AUTHOR(“yu bo”); MODULE_DESCRIPTION(“a simple linux char driver for the test”); MODULE_VERSION(“0.1”); static int majornumber; static char message[256] = {0}; static short size_of_message; static int numberopens = 0; static struct class* yuboclass = NULL; static struct device* yubodevice = NULL; static DEFINE_MUTEX(yubochar_mutex); /*
* data is being sent from the device to the user.In this case is uses the copy_to_user() function to send the buffer string to the user and captures any
@parma filep A pointer to a file object *@parma buffer The pointer to the buffer to which this function writes the *data *@parma len The length of the b *@parma offset The offset if required */ static ssize_t dev_read(struct file *filep,char *buffer, size_t len, loff_t *offset){ int error_count = 0; / * copy_to_user has the format(to, *from, size) */ error_count = copy_to_user(buffer, message, size_of_message); if(error_count == 0){ printk(KERN_INFO “yubochar: Sent %d characters to the user\n”,size_of_message); /clear the position to the start/ return (size_of_message); } else{ printk(KERN_INFO “yubochar: Failed to send %d characters to the user\n”,error_count); return -EFAULT; } } /
} module_init(yubochar_init); module_exit(yubochar_exit);