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

代碼片段和文件信息
#include?ject>
#include?
#include?
#include?“QSNTPMainWindow.h“
#include?“SntpTransform.h“
//總入口函數
int?main(int?argc?char?*argv[])
{
QApplication?a(argc?argv);
/*QSntpTransform?temp;
char*?hexChar?=?NULL;
temp.stansBinarryToHex(“1000101101“&hexChar);*/
//?設置中文字符集
QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
//?設置風格
a.setstyle(“Cleanlooks“);
QSNTPMainWindow*?mian_window?=?new?QSNTPMainWindow();
mian_window->setMinimumWidth(500);
mian_window->setMinimumHeight(500);
mian_window->show();
return?a.exec();
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????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
評論
共有 條評論