Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

linuxÏÂntpʵÏÖ

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define NTP_SERVER "clock.via.net"
#define NTP_PORT 123
//
//rfc1305 defined from 1900 so also 2208988800 (1900 - 1970 ) seconds left
//
//timeval.tv_sec + JAN_1970 = timestamp.coarse
#define JAN_1970 0x83aa7e80
//timeval.tv_usec=>timestamp.fine
#define NTPFRAC(x) (4294 * (x) + ((1981 * (x))>>11))
//timeval.tv_usec<=timestamp.fine
#define USEC(x) (((x) >> 12) - 759 * ((((x) >> 10) + 32768) >> 16))
#define Data(i) ntohl(((unsigned int *)data)[i])
#define LI 0
#define VN 3
#define MODE 3
#define STRATUM 0
#define POLL 4
#define PREC -6
struct ntptime
{
unsigned int coarse;
unsigned int fine;
};
void send_packet(int fd)
{
unsigned int data[12];
struct timeval now;
int ret;
if (sizeof(data) != 48)
{
fprintf(stderr,"size error\n");
return;
}
memset((char*)data, 0, sizeof(data));
data[0] = htonl((LI << 30) | (VN << 27) | (MODE << 24)
| (STRATUM << 16) | (POLL << 8) | (PREC & 0xff));
data[1] = htonl(1<<16); /* Root Delay (seconds) */
data[2] = htonl(1<<16); /* Root Dispersion (seconds) */
gettimeofday(&now, NULL);
data[10] = htonl(now.tv_sec + JAN_1970); /* Transmit Timestamp coarse */
data[11] = htonl(NTPFRAC(now.tv_usec)); /* Transmit Timestamp fine */
send(fd, data, 48, 0);
}
void get_udp_arrival_local_timestamp(struct ntptime *udp_arrival_local_timestamp)
{
struct timeval udp_arrival_local_time;

gettimeofday(&udp_arrival_local_time, NULL);
//print just precise to second
printf("local time=>%s\n",ctime(&(udp_arrival_local_time.tv_sec)));
}
void get_new_time(unsigned i


Ïà¹ØÎĵµ£º

¡¾×ª¡¿Linux RedHat as 5 vsftpd °²×°ÅäÖùÜÀí

°²×°rpm°ü
ÅäÖãº
ÖØÆðvsftpd·þÎñ£ºservice vsftpd restart
Æô¶¯vsftpd·þÎñ£ºservice vsftpd start
1£® ÄäÃû·þÎñÆ÷µÄÁ¬½Ó£¨¶ÀÁ¢µÄ·þÎñÆ÷£©
ÐÞ¸Ä/etc/vsftpd/vsftpd.confÅäÖÃÎļþÒ»ÏÂÏûÓÐÔòÌí¼Ó£º
Anonymous_enable=yes (ÔÊÐíÄäÃûµÇ½)
Dirmessage_enable=yes
£¨Çл»Ä¿Â¼Ê±£¬ÏÔʾĿ¼ÏÂ.messageµÄÄÚÈÝ£©
Loca ......

½«Linux´úÂëÒÆÖ²µ½WindowsµÄ¼òµ¥·½·¨(2)

¾­¹ýÉÏÊöµÄ¼¸¸ö²½Öè¡£µÚÒ»¸öÄ¿±ê£¬´úÂëÄܹ»±àÒëͨ¹ý»ù±¾ÉÏÊDz»»áÓÐʲôÎÊÌâµÄ¡£Ö»Òª°ÑÎպöþ¸öÐ޸ĴúÂëµÄ»ù±¾Ô­Ôò£¬µÚÒ»¡£ÒýÈëеĴúÂ룬¶ø²»ÐÞ¸ÄÔ­ÓеĴúÂë¡£ÔÚûÓа취½øÐе÷ÊÔǰÐÞ¸ÄÔ´´úÂëÊDz»ÔÊÐíµÄ£¬Ð޸ĵIJ»ºÃ¾Í»áÒýÆð×îºó´úÂëÔËÐÐÂß¼­µÄ»ìÂÒ£¬¶øÇÒÔÚ´úÂëÄܹ»ÔËÐÐ֮ǰÊǺÜÄÑ·¢ÏÖÎÊÌâµÄ¡£ËùÒÔ³ý·Ç·Ç³£ÓаÑÎÕ£¬·ñÔò²»Òª ......

linux¶àÏ̺߳ÃÎÄÕÂ


1
¡¢Ï̵߳Ĵ´½¨¡¢ÖÕÖ¹¼°¿ØÖÆ£º
      
Èκνø³ÌÔÚÆô¶¯Ê±¾ÍÒÑÓÐÁËÒ»¸öÖ÷Ị̈߳¬Èç¹ûÐèÒªÔÙÉú³ÉÏß³ÌÔòʹÓÃ
pthread_create
º¯Êý£¬Ôڸú¯ÊýÖпÉÒÔÖ¸¶¨Ï̵߳ÄÊôÐÔ¡¢Ïß³ÌÀý³Ì¡¢´«¸øÏß³ÌÀý³ÌµÄ²ÎÊý¡£Ïß³ÌÀý³ÌÊÇÒ»¸öÓû§×Ô¶¨ÒåµÄº¯Êý£¬¼°Ïß³ÌÖ´ÐеĴúÂë¡£µ±Ïß³ÌÀý³Ì·µ»ØÊ±£¬Ïß³ÌÔò½áÊøÔËÐУ¬ ......

Linux I2CºËÐÄ¡¢×ÜÏßÓëÉ豸Çý¶¯

Linux I2CºËÐÄ¡¢×ÜÏßÓëÉ豸Çý¶¯
×¢:
 ÔÚlinux2.6.32°æ±¾ÖÐÓÐÕâÑùµÄ´úÂëÓë×¢ÊÍ:
struct i2c_driver {
    unsigned int class;
    /* Notifies the driver that a new bus has appeared or is about to be
     * removed. You should avoid using this if y ......

Linux·¢ÐаæÓëLinux²úÆ·µÄÇø±ð






<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
-->
     Linux
·¢ÐаæÓë
Linux
²úÆ·Á½ÕßÏà²îºÜ´ó£¬ÓÐʱÈÝÒ×»ìÏý£¬·¢ÉúÎó½â£¬ÉõÖÁÒªÄÖ³ö´óЦ»°À´¡£ÎªÊ²Ã´£¿
 
       ´Ó×ÖÃæÉÏÀ´½²£¬·¢Ðа棨
Distribution
£©ºÍ²úÆ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ