Unix
bigsnowstorm
这个作者很懒,什么都没留下…
展开
-
Understanding Unix/Linux Programming note:chapter 6:为用户编程:终端控制和信号
Key-word: stty,tcgetattr, tcsetattr, fcntl, signal, 终端驱动程序的模式、阻塞/非阻塞输入一、内容概要 Chapter 6的内容是chapter 5内容的应用和扩展。用到的chapter 5的内容包括:1)使用stty命令设置终端驱动程序的属性:将终端设置为规范/非规范模式;2)使用tcgetattr, tcseta原创 2013-10-27 18:02:11 · 664 阅读 · 0 评论 -
Understanding Unix/Linux Programming 笔记:chapter 13:基于数据报(Datagram)的编程:编写许可证服务器
Key-word: 数据报socket,TCP, UDP, socket, sendto, recvfrom注:本章与chapter11对照学习基本概念: 流socke使用的网络协议叫TCP即传输控制协议(Transmission Control Protocol)。之前章节学习的客户/服务器都属于流socket。 数据报socket叫UDP,即用户数原创 2013-11-16 02:00:52 · 1111 阅读 · 0 评论 -
Understanding Unix/Linux Programming 笔记:chapter 12:连接和协议:编写Web服务器
Key-word: Web服务器 基本概念: Web服务器通常具备3种用户操作:列举目录信息、cat文件、运行程序。 本章要编写的Web服务器是对上章的ls服务器的扩展,扩展了cat文件、运行程序功能。 但如何能使一个服务器接收多个请求,实现不同的功能?用fork实现。 内容概述: 编写建立服务器端socket的函数原创 2013-11-12 23:50:52 · 743 阅读 · 0 评论 -
Understanding Unix/Linux Programming 笔记:chapter 9:可编程的shell、shell变量和环境; chapter 10:I/O重定向和管道
Chapter 9UnderstandingUnix/Linux Programming 笔记:chapter 9:可编程的shell、shell变量和环境:编写自己的shell Key-word: 本章继续完善上章的shell。新添加的功能:1)命令行解析;2)if-then-else-if流程控制;3)加入局部变量和环境变量 都是通过C函数实现,没有原创 2013-11-03 23:12:52 · 999 阅读 · 0 评论 -
Understanding Unix/Linux Programming 笔记:chapter 14:线程机制:并发函数的使用
Key-word: 线程, pthread_create, pthread_join, pthread_mutex_lock,pthread_mutex_unlock, pthread_cond_wait, pthread_cond_signal 基本概念: 在一个进程(可执行文件)中,想要同时运行几个函数,如何做?用线程实现,线程可以看做是在一个进程中同时运行的几个原创 2013-11-18 02:10:57 · 1062 阅读 · 0 评论 -
Understanding Unix/Linux Programming note:chapter 2, chapter 3, chapter 4
chapter 2:Key-word: open file, read file, who, cp, logout通过介绍who命令的编写来讲解Unix对文件的操作。who命令用于显示系统中活动用户的情况,所有的这些数据都记录在utmp文件中,以struct utmp的形式存储。因此想要获取这些信息,就必须读utmp文件。这就用到了open, read, close函数。cp命令就原创 2013-10-23 00:58:07 · 876 阅读 · 0 评论 -
Understanding Unix/Linux Programming note:chapter 1:执行可执行文件时的参数传递
1、在执行生成的可执行文件时,后面不跟任何参数,则默认传递给可执行文件的 参数个数是1,参数内容是:执行该可执行文件时的命令字符串。2、在执行生成的可执行文件时,后面跟参数,则传递可执行文件的参数个数为:1+参数的个数。如下例所示://to demonstrate the use of argument#include int main(int ac, char *av[])原创 2013-10-09 01:19:29 · 837 阅读 · 0 评论 -
Understanding Unix/Linux Programming 笔记:chapter 11:连接到近端或远端的进程:服务器与Socket(套接字)
Key-word: fdopen,dopen, socket, bind, listen, accept, connect 基本概念: 需要由其他人完成的工作称为服务,而自己则是服务的客户。 fdopen与fopen类似,返回一个FILE*类型的值,不同的是此函数以文件描述符而非文件作为参数。 fopen打开一个指向文件的带缓冲的连接;pop原创 2013-11-10 02:05:54 · 975 阅读 · 0 评论 -
Understanding Unix/Linux Programming 笔记:chapter 15:进程间通信(IPC)
Key-word: 命名管道,共享内存,文件锁,信号量, select, mkfifo, shmget(share memory get),semget(semaphore get)基本概念: IPC: InterProcess Communication 竞态条件(race condition),指两个或多个进程对共享的数据进行读或写的操作时,最终的结果原创 2013-11-21 21:42:08 · 746 阅读 · 0 评论 -
Understanding Unix/Linux Programming 笔记:chapter 8:进程和程序:编写命令解释器sh
Key-word: execvp,fork, wait基本概念: 一个可执行程序是一个机器指令及其数据的序列。一个进程是程序运行时的内存空间和设置。 进程存在于用户空间。内容概要: 本章要编写一个简单的shell。Shell最基本的功能包括: 1)运行一个程序;2)建立一个程序;3)等待exit() 这三个功能原创 2013-11-01 23:31:32 · 655 阅读 · 0 评论 -
Understanding Unix/Linux Programming 笔记:chapter 7:事件驱动编程:编写一个视频游戏
Key-word: setitimer,getitimer, signal, sigaction, 计时器,信号处理一、内容概要 本章任务:完成单人弹球游戏 先用curses库编写“hello,world”,然后用sleep()实现动画效果。Sleep() make the calling thread sleep until secondshave ela原创 2013-10-30 22:27:55 · 898 阅读 · 0 评论 -
Understanding Unix/Linux Programming note:chapter 5:连接控制:学习stty
Key-word: stty, fcntl, tcsetattr, tcgetattr 本章通过stty命令的编写讲解如何设置设备的属性。 stty命令用于让用户读取和修改终端驱动程序的设置。1、设备和文件的含义 内核在进程和外部世界间交换数据。 外部世界包括磁盘文件、终端和外部设备。(?个人理解:外部世界包括磁盘文件和外原创 2013-10-26 01:04:40 · 689 阅读 · 0 评论 -
Understanding Unix/Linux Programming note:chapter 1:more函数的流程图
书中的more01.c内共有三个函数:“从主函数判断应该从文件还是标准输入中获取数据,并打开相应的数据源,然后调用do_more函数,do_more函数将数据显示在显示器上,满一屏后,调用see_more函数接收用户的输入,以决定下一步的动作。”下面是书中代码的流程图:原创 2013-10-14 22:40:08 · 1184 阅读 · 0 评论 -
APUE NOTE
一、书中代码的编译1、README指出:To buildthe source, edit the Make.defines.* file for your system and setWKDIR to thepathname of the tree containing the source code.因此,需修改Make.defines.linux文件下的WKDIR;2、Then原创 2014-03-08 14:03:13 · 660 阅读 · 0 评论