摘要: gethostaddr#include <stdio.h>#include <net/if.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <sys/ioctl.h>#include <string.h>int main(void){ int fd; char buf[100]; struct ifreq ifr; struct sockaddr_ 阅读全文
posted @ 2012-11-08 18:17 追心 阅读(687) 评论(0) 推荐(0)
摘要: main.c 1 #include "trace.h" 2 int main(int argc,char * argv[]) 3 { 4 5 if(argc != 2) { 6 fprintf(stderr,"Usage: %s hostname\n",argv[0]); 7 exit(-1); 8 } 9 10 const int max_ttl = MYMAXTTL; 11 const int nprobes = NPROBES; 12 13 ... 阅读全文
posted @ 2012-11-08 17:21 追心 阅读(518) 评论(0) 推荐(0)
摘要: 1. struct timeval tv; 2. int ret; 3. tv.tv_sec = 10; 4. tv.tv_usec = 0; 5. if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv))<0){ 6. printf("socket option SO_RCVTIMEO not support\n"); 7. return; 8. } 9. if (( ret = recvfrom(s, buf, sizeof buf, 0, NULL,NULL)) < 0) 10. { .. 阅读全文
posted @ 2012-11-08 17:06 追心 阅读(3093) 评论(0) 推荐(1)