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

在Linux下面的调用ping

我们在网络编程的时候经常要检测系统是否得到了有效的IP,是否可以正确联通到网络里面。通常的检查方法就是使用PING命令。
而在程序里面如何自动让程序知道哩?有两种办法,
一种是利用系统的能力,直接调用系统的shell,如方法一就可以在linux系统中很好使用。
另外一种是直接在代码里面实现ping命令,通过调用函数的形式来获取系统的状态。
还有更好的办法么,如有请回复。
方法一、
#include<stdlib.h>
void main()
{
 int i;
 int count=0;
 while(1)
 {
  i=system("ping -c 1 10.27.60.122");
  printf("\ni=%d",i);
  count++;
  if(i==0)
  {
   i=system("settop install;settop odtest.out");
   break;  
  }
  if(count>3)
  {
   printf("\n error cannot reach 10.27.60.122");
   system("cd /root;ls;settop install;settop odtest.out");
   break;
  }
 }
}
方法二、
/*
 *   P I N G . C
 *
 * Using the InterNet Control Message Protocol (ICMP) "ECHO" facility,
 * measure round-trip-delays and packet loss across network paths.
 *
 * Author -
 * Mike Muuss
 * U. S. Army Ballistic Research Laboratory
 * December, 1983
 * Modified at Uc Berkeley
 *
 * Changed argument to inet_ntoa() to be struct in_addr instead of u_long
 * DFM BRL 1992
 *
 * Status -
 * Public Domain.  Distribution Unlimited.
 *
 * Bugs -
 * More statistics could always be gathered.
 * This program has to run SUID to ROOT to access the ICMP socket.
 */
#include <stdio.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h&g


相关文档:

Linux 信号(简略笔记)

    一、概要
      详细介绍:http://www.ibm.com/developerworks/cn/linux/l-ipc/part2/index1.html
       信号是UNIX和Linux系统响应结条件而产生的一个事件。接收到信号的进程会相应地采取一些行动。
    (1) 在系统 ......

[转]Linux 修改IP、DNS和路由配置

在Linux操作系统下修改IP、DNS和路由配置
ifconfig eth0 新ip
然后编辑/etc/sysconfig/network-scripts/ifcfg-eth0,修改ip
一、修改IP地址
  [aeolus@db1 network-scripts]$ vi ifcfg-eth0
  DEVICE=eth0
  ONBOOT=yes
  BOOTPROTO=static
  IPADDR=219.136.241.211
  NETMASK=255.255.255.128
   ......

Linux内核中的双循环链表

Linux内核中的双循环链表
2006-11-27 19:14
双循环链表传统实现
在传统的双循环链表实现中,如果创建某种数据结构的双循环链表,通常采用的办法是在这个数据结构的类型定义中加入两个(指向该类型对象的)指针next和prev。例如:
typedef struct foo {
    …
    struct foo *p ......

Linux常用命令表

用户系统相关命令
 用户切换
 用户切换:  su [选项] [使用者]
 用户管理
  增加用户账号:  useradd [选项] 用户名
  设置用户账号属性: usermod [选项] 属性值
  删除对应用户账号: userdel [选项] 用户名
  增加组账号: ......

linux下配置subversion

软件包:
httpd-2.23
下载地址
http://apache.justdn.org/httpd/httpd-2.2.3.tar.gz
apr-1.27
apr-util-1.27
http://apache.justdn.org/apr/,版号自已找,最好和我的所提供的版本号一样
Oracle Berkeley DB 4.0.14
下载地址
http://download.oracle.com/berkeley-db/db-4.0.14.tar.gz
subversion-1.4.0
下载地址 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号