2013年4月21日
摘要: 1 #include <unistd.h>2 int main(int argc, const char *argv[])3 {4 char* p[]={"udp-sender",NULL};5 if(execvp("/usr/local/sbin/udp-sender",p)<0)6 perror();7 return 0;8 } 阅读全文
posted @ 2013-04-21 22:52 宇睿 阅读(114) 评论(0) 推荐(0) 编辑
摘要: The rand() function returns a pseudo-random integer in the range 0 to RAND_MAX inclusive.(来自man手册)1 #include <stdio.h>2 #include <stdlib.h>3 #include <time.h>4 int main (void)5 {6 srand(time(NULL));7 printf("%d\n", 2*(rand () % 25000));8 return 0;9 } 阅读全文
posted @ 2013-04-21 16:10 宇睿 阅读(275) 评论(0) 推荐(0) 编辑
摘要: 先listen,然后获得端口 1 #include<unistd.h> 2 #include<stdio.h> 3 #include<unistd.h> 4 #include<string.h> 5 #include<signal.h> 6 #include <sys/stat.h> 7 #include <sys/types.h> 8 #include<fcntl.h> 9 #include <dlfcn.h>10 #include <errno.h>11 #include 阅读全文
posted @ 2013-04-21 15:33 宇睿 阅读(392) 评论(0) 推荐(0) 编辑