ÔÚlinuxÏ »ñÈ¡£¬Ð޸ı¾»úIPµØÖ·µÄÁ½¸öº¯Êý
//»ñÈ¡±¾»úIPµØÖ·º¯Êý
QString GetLocalIp()
{
int sock_get_ip;
char ipaddr[50];
struct sockaddr_in *sin;
struct ifreq ifr_ip;
if ((sock_get_ip=socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
printf("socket create failse...GetLocalIp!\n");
return "";
}
memset(&ifr_ip, 0, sizeof(ifr_ip));
strncpy(ifr_ip.ifr_name, "eth0", sizeof(ifr_ip.ifr_name) - 1);
if( ioctl( sock_get_ip, SIOCGIFADDR, &ifr_ip) < 0 )
{
return "";
}
sin = (struct sockaddr_in *)&ifr_ip.ifr_addr;
strcpy(ipaddr,inet_ntoa(sin->sin_addr));
printf("local ip:%s \n",ipaddr);
close( sock_get_ip );
return QString( ipaddr );
}
//Ð޸ı¾»úIPµØÖ·µÄº¯Êý
int SetLocalIp( const char *ipaddr )
{
int sock_set_ip;
struct sockaddr_in sin_set_ip;
struct ifreq ifr_set_ip;
bzero( &ifr_set_ip,sizeof(ifr_set_ip));
if( ipaddr == NULL )
return -1;
if(sock_set_ip = socket( AF_INET, SOCK_STREAM, 0 ) == -1);
{
perror("socket create failse...SetLocalIp!\n");
return -1;
}
memset( &sin_set_ip, 0, sizeof(sin_set_ip));
strncpy(ifr_set_ip.ifr_name, "eth0", sizeof(ifr_set_ip.ifr_name)-1);
sin_set_ip.sin_family = AF_INET;
sin_set_ip.sin_addr.s_addr = inet_addr(ipaddr);
memcpy( &ifr_set_ip.ifr_addr, &sin_set_ip, sizeof(sin_set_ip));
if( ioctl( sock_set_ip, SIOCSIFADDR, &ifr_set_ip) < 0 )
{
perror( "Not setup interface\n");
return -1;
}
//ÉèÖü¤»î±êÖ¾
ifr_set_ip.ifr_flags |= IFF_UP |IFF_RUNNING;
//get the status of the device
if( ioctl( sock_set_ip, SIOCSIFFLAGS, &ifr_set_ip ) < 0 )
{
perror("SIOCSIFFLAGS");
return -1;
}
close( sock_set_ip );
return 0;
}
Ïà¹ØÎĵµ£º
------------LinuxÉϹÒÔØWindows¹²ÏíĿ¼£¨ÖØÆôºóʧЧ£©--------------------
µÚÒ»²½£ºÏÈÔÚWindowsÉÏ´´½¨Ò»¸ö¹²ÏíĿ¼
µÚ¶þ²½£ºÔÚlinuxÖÐÔËÐÐÈçÏÂÃüÁ
mount.cifs //192.168.10.43/shared /root/shared -o user=name,pass=123456
×¢£º/root/sharedÊÇlinuxÉϵÄĿ¼¡£userÊÇWindowsϵͳµÄÓû§Ãû passÊÇWindo ......
ÓÐʱ²»ÒªÒÔΪprintfÒ»¶¨ÄÜ´òÓ¡³öÊý¾ÝÀ´¡£ÓÐʱ£¬Äã²»ÔÚ³ÌÐòµÄÿ¸öµØ·½printfµÄµØ·½¶¼²»¼ÓÉÏ"\n”,³ÌÐò¸ù±¾¾Í²»´òÓ¡ÈκÎÊý¾Ý³öÀ´£¬ÐŲ»£¿£¡ÎҾ͵¹Ã¹µÄÓöµ½¸öÒ»´Î¡£Óöµ½ÕâЩºÜÍ·Ì۵ģ¬»¹ÒÔΪÊdzÌÐòÄĶù³ö´í¿©¡£ÔÀ´ÕâÊÇÒòΪ£¬ËüÆäʵÓлº³åµÄ¹¦ÄÜ£¬Ö»ÓÐÔÚ“\n”£¬Ëü²Å½«»º³åÀïµÄ ......
LinuxϵĶ¨Ê±Æ÷ÓÐÁ½ÖÖ£¬ÒÔÏ·ֱð½éÉÜ£º
1¡¢alarm
Èç¹û²»ÒªÇóºÜ¾«È·µÄ»°£¬ÓÃalarm()ºÍsignal()¾Í¹»ÁË
unsigned int alarm(unsigned int seconds)
º¯Êý˵Ã÷: alarm()ÓÃÀ´ÉèÖÃÐźÅSIGALRMÔÚ¾¹ý²ÎÊýsecondsÖ¸¶¨µÄÃëÊýºó´«Ë͸øÄ¿Ç°µÄ½ø³Ì¡£Èç¹û²ÎÊýsecondsΪ0£¬Ôò֮ǰÉèÖõÄÄÖÖӻᱻȡÏû£¬²¢½«Ê£ÏµÄʱ¼ä·µ»Ø¡£
·µ»ØÖµ: ......
For all those who are beginners in any linux(ubuntu) find hard to find the package files of their distro and end up in finding an source package(which is either in tar.gz or .gz).. so now people think how to install these source files…..
lets now see how would you be installing source files ......
¾Ý¹úÍâýÌ屨µÀ£¬½üÈÕ£¬×ÊѶÍøÕ¾TechradarÁоÙÁ˽üÊ®ÄêÀ´LinuxϵͳÑݱäÀú³ÌÖеÄÖØҪʱ¿Ì£¬ÏÂÃæÈÃÎÒÃÇÀ´ä¯ÀÀÕâ15¸ö¾ßÓÐÀï³Ì±®ÒâÒåµÄ¸Ä½ø£º
1¡¢2001Äê1Ô£ºLinux Kernel 2.4
Linux 2.4°æÊÇÒ»¸öÖØÒªµÄ·ÖË®Á룬¸Ã°æ±¾ÏµÍ³ÌṩÁËÐí¶àÖØÒªµÄ½Ó¿Ú£¬ÖîÈçUSBÆô¶¯¡¢À¶ÑÀÖÕ¶ËÉ豸¡¢ÄÚǶRAIDºÍext3¸ñʽµÄÎļþϵͳ¡£Linux³öÉ«µÄÇý¶¯³ÌÐ ......