易截截图软件、单文件、免安装、纯绿色、仅160KB

linux两个程序通过共享内存通信的一个简单例子

写共享内存程序:
/*
* File: server.cpp
* Author: centos
*说明:从键盘读入数据,存放在共享内存中。
* Created on 2010年3月1日, 下午3:44
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#define BUF_SIZE 1024
#define MYKEY 114
int main(int argc, char** argv)
{
int shmid;
char *shmptr;
struct shmid_ds shmbuf;
system("ipcrm -M114"); //调试程序时用
shmid = shmget(MYKEY, BUF_SIZE, (IPC_CREAT |0777) );
if ( -1 == shmid )
{
printf("server shmget error!\n");
fprintf(stderr, "Error: %d - %s\n", errno, strerror(errno));
exit(1);
}
shmptr = (char *) (shmat(shmid, 0, 0)) ;
if ( -1 == (int) shmptr )
{
printf("server shmat error!\n");
fprintf(stderr, "Error: %d - %s\n", errno, strerror(errno));
if(shmctl(shmid,IPC_RMID,&shmbuf) < 0)
{
perror("shmctl error");
fprintf(stderr, "Error: %d - %s\n", errno, strerror(errno));
}
exit(1);
}
strcpy(shmptr,"this is a test. \n");
while(1)
{
printf("Please input:");
scanf("%s",shmptr) ;
while ('\n' != getchar() );
// fflush(stdin);
// printf("your input: %s\n", shmptr);
if (! strcmp(shmptr,"quit")) break;
}
shmdt(shmptr);
if(shmctl(shmid,IPC_RMID,&shmbuf) < 0) perror("shmctl error");
return (EXIT_SUCCESS);
}

读共享内存的程序:
/*
 * File:   main.cpp
 * Author: centos
 *
说明:从共享内存中读取数据,显示到屏幕上。
 * Created on 2010年3月2日, 上午10:47
 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#define BUF_SIZE 1024
#define M


相关文档:

学习linux的苦恼

       接触Linux也是很久的事情了,不过自我感觉却从来没有揭开过它的真面纱。从我工作以来到现在,几乎总会用到linux或在linux系统上进行工作,也一直想把linux搞懂。但是,由于总感觉Linux的庞大,英文资料难以阅读,加上自身非常的懒散,因此几次下定决心,最终还是不了了之吧。 ......

Linux定时任务系统Cron入门

cron是一个linux下的定时执行工具,可以在无需人工干预的情况下运行作业。由于Cron 是Linux的内置服务,但它不自动起来,可以用以下的方法启动、关闭这个服务:
  /sbin/service crond start //启动服务
  /sbin/service crond stop //关闭服务
  /sbin/service crond restart //重启服务
  /sbin/service cron ......

LINUX 下安装TFTP服务

TFTP是用来下载远程文件的最简单网络协议,它基于UDP协议而实现。嵌入式linux的tftp开发环境包括两个方面:一是嵌入式linux宿主机的 tftp-server支持,二是嵌入式linux目标机的tftp-client支持。因为u-boot本身内置支持tftp-client,所以嵌入式目标机就不用配置了。下面就详细介绍一下linux宿主机tftp-server的安装配置。
......

linux下nfs tftp 配置使用

linux下几种服务器的配置使用之一:nfs tftp 
安装nfs需要在服务器端关闭iptables防火墙,关闭方法如下
查看防火墙状态:
/etc/init.d/iptables status
暂时关闭防火墙:
/etc/init.d/iptables stop
禁止防火墙在系统启动时启动
/sbin/chkconfig --level 2345 iptables off
重启iptables:
/etc/init.d/iptabl ......

linux tc实现ip流量限制

tc是个配置Linux内核流量控制的工具 名字 tc - 显示/维护流量控制配置 摘要 tc qdisc [ add | change | replace | link ] dev DEV [ parent qdisc-id | root ] [ handle qdisc-id ] qdisc [ qdisc specific parameters ] tc class [ add | change | replace ] dev DEV parent qdisc-id [ classid class-id ] qd ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号