symbian openc socket 接入点 iap

选择接入点
Once you get the available access points list, the following code shows how to start a new connection using available access points.
void ConnectToAP(char *ifname)
{
ifreq ifr;
int sockfd;
 
// Name of the interface
strcpy(ifr.ifr_name, ifname);
 
sockfd = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
ioctl(sockfd,SIOCSIFNAME, &ifr);
ioctl(sockfd, SIOCIFSTART , &ifr);
 
 
// recvfrom() and sendto() operations on socket sockfd
 
ioctl(sockfd, SIOCIFSTOP, &ifr);
 
close(sockfd);
return ret;
}
获取接入点列表
void ReadAPTable()
{
struct ifconf ifc;
int sockfd;
 
sockfd = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
 
ifc.ifc_len = sizeof(ifreq) * 20;
ifc.ifc_buf = (caddr_t)malloc( ifc.ifc_len );
 
// This will get the whole access points list
// Here, ifc.ifc_len will contain the number of access points
ret = ioctl(sockfd, SIOCGIFCONF, &ifc);
 
// This will get only the active connection list
// Here, ifc.ifc_len will contain the number of active connections
ret = ioctl(sockfd, SIOCGIFACTIVECONF, &ifc);
 
close(sockfd);
free(ifc.ifc_buf);
return;
}

你可能感兴趣的:(socket,list,struct,Access,Symbian)