一个非阻塞方式的网络程序模型(UDP)

LINUX C | 发布者 小杰
Nov 11 2009
服务器端:[ssj@main test]$ cat noneasyserver.c#include <stdio.h>#include <string.h>#include <unistd.h>#include <ctype.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <stdlib.h>#include <errno.h>#include <unistd.h>#include <fcntl.h>#define MAX 80void my_turn(char *p){if (p == NULL)return;while( *p != '\0'){if( *p >= (char)0x61 && *p <= (char)0x7a)*p=(char)((int)*p-(int)0x20);p++;}}int main(void){ struct sockadd......
Read more

一个不完善的多线程服务器模型

LINUX C | 发布者 小杰
Nov 10 2009
根据:http://www.kumouse.com/article.asp?id=141中的服务端改写而成,刚学不久,只是练练手的。有高人路过,还请指点字符串长度n没有当参数传递,所以会是0,退出要第二次发数据才行,其实用消息处理函数,CTRL+C就可能搞定了[ssj@main test]$ cat rs_easyserver.c#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <ctype.h>#include <sys/socket.h>#include <arpa/inet.h>#include <string.h>#include <pthread.h>#defin......
Read more

一个服务器模型的测试(例子)

LINUX C | 发布者 小杰
Nov 09 2009
服务器端:[ssj@main test]$ cat easyserver.c#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <ctype.h>#include <sys/socket.h>#include <arpa/inet.h>#include <string.h>#define MAX 200 /*缓冲区大小*/#define BB 16 /*IP地址长度 IPV4是16,IPV6是28*/void my_turn(char *p) /*字符处理函数,小写变大写,linux下没有strupr了???*/{if (p == NULL)return;while( *p != '\0'){if( *p >= (char)0x61 && *p <= (char)0......
Read more

关于 linux 中 进程与线程 新的理解

LINUX | 发布者 小杰
Nov 09 2009
进程 比如用fork函数数建立的子进程,一个是重量级进程,他有自己独立的.data 与.bss 堆 和 栈,只是共享了父进程的代码段而以。vfork共享了父进程的一切。而说到线程,LINUX的线程的概念,我个人理解,它本来主是个轻量级的进程,线程共享父线程绝大部分资源,只有独立的栈。这么说来,进程和线程从实质上讲没有多大区别。在linux中线程只是一个轻量级的进程而以......
Read more

快速排序 - 分治策略

LINUX C | 发布者 小杰
Oct 31 2009
看了书之后,自己写了一遍,留个印记[ssj@main ~]$ cat my.c#include <stdio.h>int data[]={2,4,3,34,32,4,23,4,234,234,2,532,34,1,31,5,21,312,3,1523,12,3};quick_sort(int data[],int low,int high){int i,j,pivot;if (low<high){i=low;j=high;pivot=data[low];while(i<j){while(i<j&&data[j]>=pivot)j--;if(i<j)data[i++]=data[j];while(i<j&&data[i]<=pivot)i++;if(i<j)data[j--]=data[i];}data[i]=pivot;quick_sort(data,low,i-1);quick_sort(data,i+1,high);}}main(){int i;for(i=0;i<=22;i++){printf("%d ",data[......
Read more

进程与线程的关系

LINUX C | 发布者 小杰
Oct 31 2009
进程的两个特点:资源所有权:进程是一个可拥有资源的独立单位;调度/执行:进程同时又是一个可以独立调度和分派的基本单位;引入线程的目的: 因为进程是一个资源拥有者,因而在进程的创建、撤消和切换中,系统必须为之付出较大的时空开销。也因此,在系统中所设置的进程数目不宜过多,进程切换的频率也不宜过高,同时也限制了并发程序的进一步提高。在操作系统中引入线程,是为了减少程序并发......
Read more

C 优先级与结合性

LINUX C | 发布者 小杰
Oct 31 2009
优先级:决定哪部分表达式先计算。结合性:计算时是从左向右顺序,还是从右向左的顺序。例1:b=++a;先看优先级:++ 优先级比 = 要高,先算++。再看结合性:++ 的结合性是从右到左,这里就是它,直接算。现在就剩下 = 号了,优先级就它一个了,但结合性还是 从右到左,那么现在把a 的值取出来赋值给 b 。所以: 整个结果相当于a = a + 1; b=a;例2:b=a++;先看优先级,++ 虽然高,但是后置的(它的结合性是从左到右),......
Read more

ssh 配置 ssh_config sshd_config

LINUX | 发布者 小杰
Oct 26 2009
ssh_config# Host *  (只对能够匹配后面字串的计算机有效。“*”表示所有的计算机)# ForwardAgent no  (设置连接是否经过验证代理(如果存在)转发给远程计算机)# ForwardX11 no  (设置X11连接是否被自动重定向到安全的通道和显示集)# RhostsRSAAuthentication no  (设置是否使用用RSA算法的基于rhosts的安全验证)# RSAAuthentication yes  (设置是否使用RSA算法进行安全验证)# PasswordAuthentication yes  ......
Read more

rpm 相关 依赖

LINUX | 发布者 小杰
Oct 26 2009
查看一个rpm包的依赖如果是本地的包,没有安装过的rpm -qRp 包名[root@mydisk ~]# rpm -qR /home/linux/tools/VMware-Workstation-6.5.2-156735.x86_64.rpm package /home/linux/tools/VMware-Workstation-6.5.2-156735.x86_64.rpm is not installed[root@mydisk ~]# rpm -qR /home/linux/tools/VMware-Workstation-6.5.3-185404.x86_64.bundle package /home/linux/tools/VMware-Workstation-6.5.3-185404.x86_64.bundle is not installed[root@mydisk ~]# rpm -qR /home/linux/tools/tftp-server-0.32-4.i386.rpm package /home/linux/tools/tftp-server-0.32-4.i386.r......
Read more

一个基木的小游戏

个人的心情空间 | 发布者 小杰
Oct 24 2009
http://i3.sinaimg.cn/gm/downgames/littlegame/U1850P115T33D3906F646DT20090302115435.sw......
Read more
21 中的第 8 页« 第一页...67891020...最后一页 »