資源簡(jiǎn)介
這幾天需要使用QT寫個(gè)SNTP發(fā)布服務(wù)。最近用QT,就使用QT的特性,寫了包含TCP和UDP的簡(jiǎn)易框架。已測(cè)能用(使用網(wǎng)絡(luò)抓包工具可解析出NTP數(shù)據(jù))。
最主要的的是(1)QTCP
(2)QUDP
(3)基于SNTP要求的數(shù)據(jù)格式轉(zhuǎn)換
基本注釋添加很全面,有點(diǎn)基礎(chǔ)的都能明白。
代碼中用到的QString和QDateTime特性很少,而且完全可以用C++類型替換

代碼片段和文件信息
#include?ject>
#include?
#include?
#include?“QSNTPMainWindow.h“
#include?“SntpTransform.h“
//總?cè)肟诤瘮?shù)
int?main(int?argc?char?*argv[])
{
QApplication?a(argc?argv);
/*QSntpTransform?temp;
char*?hexChar?=?NULL;
temp.stansBinarryToHex(“1000101101“&hexChar);*/
//?設(shè)置中文字符集
QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
//?設(shè)置風(fēng)格
a.setstyle(“Cleanlooks“);
QSNTPMainWindow*?mian_window?=?new?QSNTPMainWindow();
mian_window->setMinimumWidth(500);
mian_window->setMinimumHeight(500);
mian_window->show();
return?a.exec();
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????1108??2013-05-30?16:52??SNTP_Project.pro
?????文件????????620??2013-06-27?08:37??src\main.cpp
?????文件???????5047??2013-07-04?15:38??src\Qba
?????文件????????800??2013-06-02?20:06??src\QSNTPMainWindow.cpp
?????文件????????575??2013-06-02?20:05??src\QSNTPMainWindow.h
?????文件???????6184??2013-06-27?17:02??src\QSNTPSettingGroupBox.cpp
?????文件???????2583??2013-06-27?16:51??src\QSNTPSettingGroupBox.h
?????文件???????2342??2013-07-04?15:38??src\QTcpServerSNTP.cpp
?????文件????????887??2013-06-27?10:51??src\QTcpServerSNTP.h
?????文件???????2884??2013-07-04?15:38??src\QUdpServerSNTP.cpp
?????文件???????1285??2013-05-31?11:21??src\QUdpServerSNTP.h
?????文件??????20696??2013-07-04?15:38??src\SntpTransform.cpp
?????文件???????2819??2013-07-04?15:38??src\SntpTransform.h
?????目錄??????????0??2013-07-04?15:50??src
-----------?---------??----------?-----??----
????????????????47830????????????????????14
評(píng)論
共有 條評(píng)論