Welcome![Sign In][Sign Up]
Location:
Search - setsockopt

Search list

[Windows Mobileopttest

Description: This a sample Bluetooth application which illustrates the use of Windows CE Bluetooth stack WinSock getsockopt/setsockopt programming interfaces.-This a sample Bluetooth application which illustrates the use of Windows CE Bluetooth stack WinSock getsockopt/setsockopt programming interfaces.
Platform: | Size: 8434 | Author: | Hits:

[Internet-Networksetsockopt

Description: linux c 网络编程 测试函数setsockopt
Platform: | Size: 2233 | Author: 游铭 | Hits:

[Internet-Network一个判断远程主机存活程序代码

Description: 一个判断远程主机存活程序代码(ping) #include #include #include #include #include "winsock.h" #pragma comment(lib,"Ws2_32"); #define SEND_SIZE 32 #define PACKET_SIZE 4096 #define ICMP_ECHO 8 #define ICMP_ECHOREPLY 0 struct icmp { unsigned char icmp_type; unsigned char icmp_code; unsigned short icmp_cksum; unsigned short icmp_id; unsigned short icmp_seq; unsigned long icmp_data; }; struct ip { unsigned char ip_hl:4; unsigned char ip_v:4; unsigned char ip_tos; unsigned short ip_len; unsigned short ip_id; unsigned short ip_off; unsigned char ip_ttl; unsigned char ip_p; unsigned short ip_sum; unsigned long ip_src; unsigned long ip_dst; }; unsigned char sendpacket[PACKET_SIZE]; unsigned char recvpacket[PACKET_SIZE]; struct sockaddr_in dest_addr; struct sockaddr_in from_addr; int sockfd; int pid; unsigned short cal_chksum(unsigned short *addr,int len); int pack(int pack_no); int unpack(unsigned char *buf,int len); void send_packet(void); void recv_packet(void); void main(int argc,char *argv[]) { struct hostent *host; struct protoent *protocol; WSADATA wsaData; int timeout=1000; int SEND_COUNT=4; int i; char *par_host; par_host=argv[argc-1]; //IP赋值 switch(argc) { case 2: break; case 3: if(strcmp(argv[1],"-t")==0) { SEND_COUNT=10000; break; } //fall through default: printf("usage: %s [-t] Host name or IP address\n",argv[0]); exit(1); } if(WSAStartup(0x1010,&wsaData)!=0) { printf("wsastartup error\n"); exit(1); } if( (protocol=getprotobyname("icmp") )==NULL) { printf("getprotobyname error\n"); exit(1); } /* printf("%s\n",protocol->p_name); printf("%s\n",protocol->p_aliases); printf("%d\n",protocol->p_proto); system("pause"); */ if( (sockfd=socket(AF_INET,SOCK_RAW,protocol->p_proto) )<0) { printf("socket error\n"); exit(1); } if(setsockopt(sockfd,SOL_SOCKET,SO_RCVTIMEO,(char*)&timeout,sizeof(timeout))h_length); //resolve address to hostname if(host=gethostbyaddr(host->h_addr,4,PF_INET)) par_host=host->h_name; // //printf("%s\n",par_host); // } else if( dest_addr.sin_addr.s_addr=inet_addr(par_host)==INADDR_NONE) { printf("Unkown host %s\n",par_host); exit(1); } pid=getpid(); /* printf("%d\n",pid); system("pause"); */ printf("Pinging %s [%s]: with %d bytes of data:\n\n",par_host,inet_ntoa(dest_addr.sin_addr),SEND_SIZE); for(i=0;i1) { sum+=*w++; nleft-=2; } if( nleft==1) { *(unsigned char *)(&answer)=*(unsigned char *)w; sum+=answer; } sum=(sum>>16)+(sum&0xffff); sum+=(sum>>16); answer=~sum; return answer; } //打包 int pack(int pack_no) { int packsize; struct icmp *icmp; packsize=8+SEND_SIZE; icmp=(struct icmp*)sendpacket; icmp->icmp_type=ICMP_ECHO; icmp->icmp_code=0; icmp->icmp_cksum=0; icmp->icmp_seq=pack_no; icmp->icmp_id=pid; icmp->icmp_data=GetTickCount(); icmp->icmp_cksum=cal_chksum( (unsigned short *)icmp,packsize); /*校验算法*/ return packsize; } //解包 int unpack(unsigned char *buf,int len) { struct ip *ip; struct icmp *icmp; double rtt; int iphdrlen; ip=(struct ip *)buf; iphdrlen=ip->ip_hl*4; icmp=(struct icmp *)(buf+iphdrlen); if( (icmp->icmp_type==ICMP_ECHOREPLY) && (icmp->icmp_id==pid) ) { len=len-iphdrlen-8; rtt=GetTickCount()-icmp->icmp_data; printf("Reply from %s: bytes=%d time=%.0fms TTL=%d icmp_seq=%u\n", inet_ntoa(from_addr.sin_addr), len, rtt, ip->ip_ttl, icmp->icmp_seq); return 1; } return 0; } //发送 void send_packet() { int packetsize; static int pack_no=0; packetsize=pack(pack_no++); if( sendto(sockfd,(char *)sendpacket,packetsize,0,(struct sockaddr *)&dest_addr,sizeof(dest_addr) )=0) success=unpack(recvpacket,n); else if (WSAGetLastError() == WSAETIMEDOUT) { printf("Request timed out.\n"); return; } }while(!success); } UID5380 帖子239 精华0 积分1289 阅读权限40 来自软件学院 在线时间81 小时 注册时间2006-5-22 最后登录2007-2-24 查看详细资料 TOP
Platform: | Size: 5881 | Author: shuiyuan313 | Hits:

[SourceCodesendto

Description: 实现Linux发送功能-Send to achieve Linux
Platform: | Size: 1024 | Author: | Hits:

[Windows Mobileopttest

Description: This a sample Bluetooth application which illustrates the use of Windows CE Bluetooth stack WinSock getsockopt/setsockopt programming interfaces.-This a sample Bluetooth application which illustrates the use of Windows CE Bluetooth stack WinSock getsockopt/setsockopt programming interfaces.
Platform: | Size: 8192 | Author: | Hits:

[Internet-Networksetsockopt

Description: linux c 网络编程 测试函数setsockopt-linux c programming network test function setsockopt
Platform: | Size: 2048 | Author: | Hits:

[Communicationsocket

Description: 我们自己创建各个的头部,系统只是把它们发送出去. 在实例中,由于我们要修改我们的源IP地址, 所以我们使用了setsockopt函数,如果我们只是修改TCP数据,那么IP数据一样也可以由系统来创建的. -To create all our own head, the system only to send them out. In the example, because we have to modify our source IP address, so we use the setsockopt function, if we just amend the TCP data, then the IP can also be from the same data system to create the.
Platform: | Size: 5120 | Author: zhangjianrong | Hits:

[Ftp Clientbabyftp

Description: testbox1: {/home/p-t/slacker/public_html} ftp -d testbox2 Connected to testbox2.slacksite.com. 220 testbox2.slacksite.com FTP server ready. Name (testbox2:slacker): slacker ---> USER slacker 331 Password required for slacker. Password: TmpPass ---> PASS XXXX 230 User slacker logged in. ---> SYST 215 UNIX Type: L8 Remote system type is UNIX. Using binary mode to transfer files. ftp> passive Passive mode on. ftp> ls ftp: setsockopt (ignored): Permission denied ---> PASV 227 Entering Passive Mode (192,168,150,90,195,149). ---> LIST 150 Opening ASCII mode data connection for file list drwx------ 3 slacker users 104 Jul 27 01:45 public_html 226 Transfer complete. ftp> quit ---> QUIT 221 Goodbye.-testbox1: {/home/p-t/slacker/public_html} ftp-d testbox2 Connected to testbox2.slacksite.com. 220 testbox2.slacksite.com FTP server ready. Name (testbox2:slacker): slacker ---> USER slacker 331 Password required for slacker. Password: TmpPass ---> PASS XXXX 230 User slacker logged in. ---> SYST 215 UNIX Type: L8 Remote system type is UNIX. Using binary mode to transfer files. ftp> passive Passive mode on. ftp> ls ftp: setsockopt (ignored): Permission denied ---> PASV 227 Entering Passive Mode (192,168,150,90,195,149). ---> LIST 150 Opening ASCII mode data connection for file list drwx------ 3 slacker users 104 Jul 27 01:45 public_html 226 Transfer complete. ftp> quit ---> QUIT 221 Goodbye.
Platform: | Size: 40960 | Author: Omk | Hits:

[Linux-Unixsetopt

Description: getsockopt/setsockopt的应用操作,应用程序和内核进行通讯的方式-a getsockopt/the setsockopt the application and operation, application and kernel means of communication
Platform: | Size: 2048 | Author: 张展 | Hits:

[Internet-Networkddos

Description: 原始套接字和一般的套接字不同的是以前许多由系统做的事情,现在要由我们自己来做了。 不过这里面是不是有很多的乐趣呢。 当我们创建了一个 TCP套接字的时候,我们只是负责把我们要发送的内容(buffer)传递给了系统。 系统在收到我们的数据后,回自动的调用相应的模块给数据加上TCP 头部,然后加上IP头部。 再发送出去。而现在是我们自己创建各个的头部,系统只是把它们发送出去。 在上面的实例中,由于我们要修改我们的源IP地址, 所以我们使用了setsockopt函数,如果我们只是修改TCP数据,那么IP数据一样也可以由系统来创建的。-syn packer
Platform: | Size: 2048 | Author: testforxxll | Hits:

[Program docsetsockopt

Description: 这是一篇对socket的设置进行深入介绍的资料文档,供对网络开发有深入了解的人士学习参考。-This is one pair of socket setting depth description document for reference in-depth understanding of the people to learn web development.
Platform: | Size: 141312 | Author: enchen | Hits:

[Internet-Networklinux-socket

Description: linux下简单的C/S模式的TCP编程,应用select()处理阻塞问题。 setsockopt()处理重启服务器出现“Address already in use”的情况。-the TCP programming under linux simple C/S mode, select () blocking problem. setsockopt () processing restart the server " Address already in use" .
Platform: | Size: 3072 | Author: | Hits:

[Internet-NetworkAdvanced-Socket-Programs-SCTP-Setsock-thread-safe

Description: This document contains all easy-to-get and simple tcp/ip socket programs. like thread safe version of gethostbyaddr, sctp programs, ping c code, setsockopt&getsockopt programs
Platform: | Size: 1054720 | Author: imranity | Hits:

[Linux-Unixtermbits

Description: mask for the fwd methods.The struct ip_vs_service_user and struct ip_vs_dest_user are used to set IPVS rules through setsockopt.
Platform: | Size: 4096 | Author: cqyonrin | Hits:

CodeBus www.codebus.net