linux ʱ¼ä&¶¨Ê±Æ÷ ½éÉÜ
1.ʱ¼ä±íʾ
¡¡¡¡ÔÚ³ÌÐòµ±ÖÐ,ÎÒÃǾ³£ÒªÊä³öϵͳµ±Ç°µÄʱ¼ä,±ÈÈçÎÒÃÇʹÓÃdateÃüÁîµÄÊä³ö½á¹û.Õâ¸öʱºòÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæÁ½¸öº¯Êý:
¡¡¡¡#include
¡¡¡¡time_t time(time_t *tloc);
¡¡¡¡char *ctime(const time_t *clock);
¡¡¡¡timeº¯Êý·µ»Ø´Ó1970Äê1ÔÂ1ÈÕ0µãÒÔÀ´µÄÃëÊý.´æ´¢ÔÚtime_t½á¹¹Ö®ÖÐ.²»¹ýÕâ¸öº¯ÊýµÄ·µ»ØÖµ¶ÔÓÚÎÒÃÇÀ´ËµÃ»ÓÐʲôʵ¼ÊÒâÒå.Õâ¸öʱºòÎÒÃÇʹÓõڶþ¸öº¯Êý½«ÃëÊýת»¯Îª×Ö·û´®. Õâ¸öº¯ÊýµÄ·µ»ØÀàÐÍÊǹ̶¨µÄ:Ò»¸ö¿ÉÄÜֵΪ.Thu Dec7 14:58:59 2000 Õâ¸ö×Ö·û´®µÄ³¤¶ÈÊǹ̶¨µÄΪ26.
2.ʱ¼äµÄ²âÁ¿
¡¡¡¡ÓÐʱºòÎÒÃÇÒª¼ÆËã³ÌÐòÖ´ÐеÄʱ¼ä.±ÈÈçÎÒÃÇÒª¶ÔËã·¨½øÐÐʱ¼ä·ÖÎö.Õâ¸öʱºò¿ÉÒÔʹÓÃÏÂÃæÕâ¸öº¯Êý. #include
¡¡¡¡int gettimeofday(struct timeval *tv,struct timezone *tz);
¡¡¡¡strut timeval {
¡¡¡¡long tv_sec; /* ÃëÊý */
¡¡¡¡long tv_usec; /* ΢ÃëÊý */
¡¡¡¡};
¡¡¡¡gettimeofday½«Ê±¼ä±£´æÔڽṹtvÖ®ÖÐ.tzÒ»°ãÎÒÃÇʹÓÃNULLÀ´´úÌæ.
3.¼ÆʱÆ÷µÄʹÓÃ
3.1¡¢alarm
-------------------------------------------
Èç¹û²»ÒªÇóºÜ¾«È·µÄ»°£¬ÓÃalarm()ºÍsignal()¾Í¹»ÁË
unsigned int alarm(unsigned int seconds)
º¯Êý˵Ã÷: alarm()ÓÃÀ´ÉèÖÃÐźÅSIGALRMÔÚ¾¹ý²ÎÊýsecondsÖ¸¶¨µÄÃëÊýºó´«Ë͸øÄ¿Ç°µÄ½ø³Ì¡£Èç¹û²ÎÊýsecondsΪ0£¬Ôò֮ǰÉèÖõÄÄÖÖӻᱻȡÏû£¬²¢½«Ê£ÏµÄʱ¼ä·µ»Ø¡£
·µ»ØÖµ: ·µ»Ø֮ǰÄÖÖÓµÄÊ£ÓàÃëÊý£¬Èç¹û֮ǰδÉèÄÖÖÓÔò·µ»Ø0¡£
alarm()Ö´Ðк󣬽ø³Ì½«¼ÌÐøÖ´ÐУ¬ÔÚºóÆÚ(alarmÒÔºó)µÄÖ´Ðйý³ÌÖн«»áÔÚsecondsÃëºóÊÕµ½ÐźÅSIGALRM²¢Ö´ÐÐÆä´¦Àíº¯Êý¡£
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
void sigalrm_fn(int sig)
{
printf("alarm!\n");
alarm(2);
return;
}
int main(void)
{
signal(SIGALRM, sigalrm_fn);
alarm(1);
while(1) pause();
}
3.2¡¢setitimer()
-------------------------------------------
int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue));
setitimer()±Èalarm¹¦ÄÜÇ¿´ó£¬Ö§³Ö3ÖÖÀàÐ͵Ķ¨Ê±Æ÷£º
ITIMER_REAL :&nb
Ïà¹ØÎĵµ£º
linux—selectÏê½â
selectϵͳµ÷ÓÃʱÓÃÀ´ÈÃÎÒÃǵijÌÐò¼àÊÓ¶à¸öÎļþ¾ä±úµÄ״̬±ä»¯µÄ¡£³ÌÐò»áÍ£ÔÚselectÕâÀïµÈ´ý£¬Ö±µ½±»¼àÊÓµÄÎļþ¾ä±úÓÐÒ»¸ö»ò¶à¸ö·¢ÉúÁË״̬¸Ä±ä¡£
¹ØÓÚÎļþ¾ä±ú£¬Æäʵ¾ÍÊÇÒ»¸öÕûÊý£¬Í¨¹ýsocketº¯ÊýµÄÉùÃ÷¾ÍÃ÷°×ÁË£º
int socket(int domain, int type, int protocol);
ÎÒÃÇ×îÊìϤµÄ¾ä±úÊÇ0¡¢1¡¢2 ......
1¡£»ù´¡ÖªÊ¶
linuxÌṩ·þÎñÊÇÓÉÔËÐÐÔÚºǫ́µÄÊØ»¤³ÌÐò£¨daemon£©À´Ö´Ðеġ£
ÊØ» ......
Ò»£®Ç°ÑÔ
¡¡¡¡LinuxÓµÓзḻ¸÷ÖÖÔ´´úÂë×ÊÔ´,µ«ÊǴ󲿷ִúÂëÔÚWindowsƽ̨Çé¿öÊÇÎÞ·¨Õý³£±àÒëµÄ¡£Windowsƽ̨¸ù±¾ÎÞ·¨Ö±½ÓÀûÓÃÕâЩԴ´úÂë×ÊÔ´¡£Èç¹ûÏëҪʹÓÃÍêÕûµÄ´úÂ룬¾ÍÒª×öÒÆÖ²¹¤×÷¡£ÒòΪC/C++ LibraryµÄ²»Í¬ºÍÆäËûµÄһЩÔÒò£¬ÒÆÖ²C/C++´úÂëÊÇÒ»ÏîÀ§ÄѵŤ×÷¡£±¾ÎĽ«ÒÔÒ»¸öʵ¼ÊµÄÀý×Ó£¨Tar£©À´ËµÃ÷ÈçºÎ°ÑLinux´úÂëÒÆÖ² ......
Linux NetfilterʵÏÖ»úÖƺÍÀ©Õ¹¼¼Êõ
¼¶±ð£º ³õ¼¶
ÑîɳÖÞ
(pubb@163.net
)¹ú·À¿Æ¼¼´óѧ¼ÆËã»úѧԺ
2003 Äê 3 ÔÂ 01 ÈÕ
http://www.ibm.com/developerworks/cn/linux/l-ntflt/
2.4.xµÄÄÚºËÏà¶ÔÓÚ2.2.xÔÚIPÐÒéÕ»²¿·ÖÓбȽϴóµÄ¸Ä¶¯£¬
Netfilter-iptables¸üÊÇÆäÒ»´óÌØÉ«£¬ÓÉÓÚËü¹¦ÄÜÇ¿´ó£¬²¢ÇÒÓë ......
linux¿âÎļþ±àдÈëÃÅ
Ò»¡¢ÎªÊ²Ã´ÒªÊ¹ÓÿâÎļþ
ÎÒÃÇÔÚʵ¼Ê±à³Ì¹¤×÷Öп϶¨»áÓöµ½ÕâÖÖÇé¿ö£ºÓм¸¸öÏîÄ¿ÀïÓÐһЩº¯ÊýÄ£¿éµÄ¹¦ÄÜÏàͬ£¬
ʵÏÖ´úÂëÒ²Ïàͬ£¬Ò²ÊÇÎÒÃÇËù˵µÄÖظ´´úÂë¡£±ÈÈ磬ºÜ¶àÏîÄ¿ÀﶼÓÐÒ»¸öÓû§ÑéÖ¤µÄ¹¦ÄÜ¡£
´úÂë¶ÎÈçÏ£º
//UserLogin.hÎļþ£¬Ìṩº¯ÊýÉùÃ÷
int IsValidUser(char ......