代码改变世界

随笔分类 -  Linux

多客户模式

2012-07-10 15:45 by Rollen Holt, 486 阅读, 收藏, 编辑
摘要: #include <sys/types.h>#include <sys/time.h>#include <stdio.h>#include <stdlib.h>#include <sys/ioctl.h>#include <fcntl.h>#include <unistd.h>#include <sys/socket.h>#include <netinet/in.h>int main(int argc, char const *argv[]){ int server_sockfd, cl 阅读全文

Linux c学习--进程基础学习

2012-06-02 16:04 by Rollen Holt, 945 阅读, 收藏, 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <unistd.h>int main(int argc, char const *argv[]){ printf("I am process %ld\n", (long)getpid() ); printf("My parent is %ld\n", (long)getppid()); return 0;}上面的例子输出了进程的ID和他的父进程的ID#include <unistd.h>#include <st 阅读全文

Linux c基础学习

2012-06-02 15:58 by Rollen Holt, 691 阅读, 收藏, 编辑
摘要: #include <stdio.h>#include <stdlib.h>int myarray[50000]={1,2,3,4,5};int main(int argc, char const *argv[]){ return 0;}#include <stdio.h>#include <stdlib.h>int myarray[50000];int main(int argc, char const *argv[]){ myarray[0]=3; return 0;}如果你用ls -l命令查看上面的2个程序文件的话,你就会发现两个文件的大小差 阅读全文

一些服务器客户端的c例子

2012-05-31 09:41 by Rollen Holt, 1658 阅读, 收藏, 编辑
摘要: 今天早上6点起床之后练习的一些c的网络编程的基础例子client1/* Make the necessary includes and set up the variables. */#include <sys/types.h>#include <sys/socket.h>#include <stdio.h>#include <sys/un.h>#include <unistd.h>#include <stdlib.h>int main(){ int sockfd; int len; struct sockaddr_un 阅读全文

linux一些杂项整理

2012-05-19 23:10 by Rollen Holt, 571 阅读, 收藏, 编辑
摘要: 如果一个目录或者文件名以.开始,那么这个文件或者目录就是隐藏的,如果使用默认的方式是看不到的。/bin 目录存放的是常用的可执行文件或者程序sbin 目录存放的是系统的可执行文件///////////////////////google linux各个目录的作用超级用户的home目录是/root 普通用户的目录是/home/rollen在linux文件系统中的另外一个重要的目录是挂载点,当linux检测到可移植性硬件被插入到系统的时候,就会自动产生一个挂载点,一般情况下光盘被挂载在/media/CDRom 软盘被挂载在/media/floppy linux的文件名和目录名是区分大小写的who. 阅读全文

Ubuntu打开pdf,中文无法显示的解决方案

2012-05-19 10:01 by Rollen Holt, 493 阅读, 收藏, 编辑
摘要: 最近发现Ubuntu下打开很多PDF文档后[无论用文档管理器(evince),还是Okular],许多地方显示空白,估计是中文显示不正常。Google了很久都没解决,最后在Ubuntu 中文论坛找到解决方法。参见7楼的解决方案:1 sudo apt-get install poppler-data安装cmap,然后,无论用evince还是Okular均可以正常显示中文了! 阅读全文

《UNIX环境高级编程》第一章总结

2012-05-18 23:17 by Rollen Holt, 613 阅读, 收藏, 编辑
摘要: 第一章 UNIX 技术知识 unix的口令文件一般情况下是/etc/passwd文件 口令文件中的登录项一般有7个以冒号进行分割的字段组成:登录名,加密扣了,数字用户ID(224),数字组ID(20),注释字段,起始目录(比如:/home/rollen),以及shell程序(/bin/ksh)。 unix目录的起始目录叫做root,他的名字是一个字符/ stat和fstat函数返回一个包含... 阅读全文