Time of Update: 2018-12-07
if(pcap_findalldevs(&device,errbuf)==0 ) ...{ device_t=device; device_t=device_t->next; printf("網路介面卡列表: "); while(device_t) ...{ printf(" [%d]:%s
Time of Update: 2018-12-07
一.socket的一些基本結構1.32位的IP地址:struct in_addr{ unsigned long s_addr;}2.TCP/IP所在的網際通訊域使用的通訊端地址格式:struct sockaddr_in{ short int sin_family; //表示所屬地址簇,TCP/IP必須是AF_INET unsigned short int sin_port; //表示連接埠號碼 struct in_addr sin_addr;
Time of Update: 2018-12-07
View Code 1 const int maxqueue = 50; 2 3 enum Error_code 4 { 5 success, overflow, underflow, fail //沒有; 6 }; 7 8 template<class T> 9 class Queue10 {11 public:12 Queue();13 bool empty() const;14 Error_code serve();15
Time of Update: 2018-12-07
View Code 1 #include<limits.h> 2 #include<time.h> 3 4 class Random 5 { 6 public: 7 Random(bool pseudo = true); 8 virtual ~Random(); 9 double random_real();10 int random_integer(int low, int high);11 private:12 int
Time of Update: 2018-12-07
昨天突然被一位朋友問到了關於檔案結尾的程式問題。在用feof()判斷檔案時,複製會多產生一個字元。 這個問題在大一的時候,老師上課就強調過,但那時只是模糊的記得個大概,記得這個函數如果用的不對就是會出現問題,解決是要先讀一下,然後再判斷,具體的什麼還真實忘了。而且平常經常用的EOF,所以這個問題自己並沒有一個特別好的概念。現在寫的C語言多了,應該能理解這個問題存在的原因。所以就在網上找了好多關於這個問題的解釋,一看還真不少,但是好多都說的不清除,讓人看完後,感覺默默糊糊的。但是還是在其中學到了不
Time of Update: 2018-12-07
pcap_pkthdr結構 [路徑]/usr/include/pcap.h /* * Each packet in the dump file is prepended with this generic header. * This gets around the problem of different headers for different * packet interfaces. */ struct pcap_pkthdr { struct timeval
Time of Update: 2018-12-07
第二部分 資料通訊本部分 資料通訊系統 點對點或多點鏈路 討論的主題 資料轉送問題 3、資料轉送形式 4、傳輸媒體 5、編碼技術 6、資料通訊 可靠性問題 7、資料連結控制協議 效率問題 8、複用 無線通訊 9 、擴頻 第三章
Time of Update: 2018-12-07
/** 使用深度優先選擇(DFS)演算法,給定5個數,寫下其中任意3個數的組合* 使用遞迴方法,分為1個數、2個數、3個數 三層,並傳進起始下標*/#include <stdio.h>#define NUM_ALL 5#define NUM_SELECT 3int sum = 0;int a[6] = {0,1,2,3,4,5};int index[4];void SumIsNine(){if (sum == 9) { printf("Sum is 9:
Time of Update: 2018-12-07
在TCP/IP協議中,TCP協議提供可靠的串連服務,採用三向交握建立一個串連。第一次 第一次握手:建立串連時,用戶端發送syn包(syn=j)到伺服器,並進入SYN_SEND狀態,等待伺服器確認;SYN:同步序列編號(Synchronize Sequence
Time of Update: 2018-12-07
這是網路編程的基礎,tcp的狀態轉移圖說到底就是一個狀態機器的不同狀態之間的轉換關係以及觸發這些狀態需要的條件,一共存在11個狀態,我們來逐一分析:1.CLOSED:起始點,在逾時或者串連關閉時候進入此狀態。2.LISTEN:svr端在等待串連過來時候的狀態,svr端為此要調用socket,
Time of Update: 2018-12-07
1 static u32 flow_count = 0;2 static u32 increase = 10;3 static int flow_pos = -1;4 static struct osdpi_flow **allflow = NULL; 1 clock_t now_clock = clock();2 for (i = 0; i <= flow_pos; i++) {3 if ((now_clock -
Time of Update: 2018-12-07
char * strtok ( char * string, const char * delimiters ); Sequentially truncate string if delimiter is found. If string is not NULL, the function scans string for the first occurrence of any character included in delimiters. If it is found, the
Time of Update: 2018-12-07
// 如果你要對b值進行修改就這樣定義void fun( int & b ){// ... }//如果你只需使用b不變數裡的值這樣定義,對於大的對象這樣定義運行速度就要快很多void fun1( const int & b ){}main(){int n = 10; fun( n ); //調用時在記憶體中要重新構造一個 fun1( n ); // 調用時直接將n的地址傳給fun1的參數b,不會在記憶體中重新構造
Time of Update: 2018-12-07
寫出一個struct,然後sizeof,你會不會經常對結果感到奇怪?sizeof的結果往往都比你聲明的變數總長度要大,這是怎麼回事呢?講講位元組對齊吧. /******************************分割線如果體繫結構是不對齊的,A中的成員將會一個挨一個儲存,從而sizeof(a)為11。顯然對齊更浪費了空間。那麼為什麼要使用對齊呢?體繫結構的對齊和不對齊,是在時間和空間上的一個權衡。對齊節省了時間。假設一個體繫結構的字長為w,那麼它同時就假設了在這種體繫結構上對寬度為w的資料的
Time of Update: 2018-12-07
第8章 複用頻分複用時分複用 同步時分複用 統計時分複用非對稱式數位用戶線路路 第8章 複用高效利用高速資料通訊鏈路----複用 單個資料鏈路的容量可以被多個資訊源所共用複用被廣泛使用的原因 資料速率越高,傳輸設施的性價比越高 多數資料通信設備所需的資料率相對不高8.1 頻分複用FDM (Frequency Division
Time of Update: 2018-12-07
#include <string.h>#include <sys/socket.h>#include <sys/ioctl.h>#include <net/if.h>#include <stdio.h>#include <netinet/in.h>#include <arpa/inet.h>int main(){int inet_sock;struct ifreq ifr; inet_sock =
Time of Update: 2018-12-07
文章目錄 函數簡介程式樣本 C語言函數fopen函數簡介函數功能: 開啟一個檔案函數原型:FILE * fopen(const char * path,const char * mode);相關函數:open,fclose,fopen_s引 ,_wfopen所需庫: <stdio.h>傳回值: 檔案順利開啟後,指向該流的檔案指標就會被返回。如果檔案開啟失敗則返回NULL,並把錯誤碼存在errno
Time of Update: 2018-12-07
1. 圖形模式登入時,順序讀取:/etc/profile和~/.profile2. 圖形模式登入後,開啟終端時,順序讀取:/etc/bash.bashrc和~/.bashrc3. 文字模式登入時,順序讀取:/etc/bash.bashrc,/etc/profile和~/.bash_profile4. 從其它使用者su到該使用者,則分兩種情況: (1)如果帶-l參數(或-參數,--login參數),如:su
Time of Update: 2018-12-07
基於這一點“從許多優質的網頁連結過來的網頁,必定還是優質網頁”。 提高PageRank的要點有3個:反向連結數(單純意義上的受歡迎度指標)反向連結是否來自推薦度高的頁面(有根據的受歡迎指標)反向連結源頁面的串連數(被選中的幾率指標) 下面,舉一個例子。 ,表示頁面間互相連結關係 連結源ID 連結目標ID1 2,3,4,5,72 13 1,2 4 2,3,55 1,3
Time of Update: 2018-12-07
格式:int fgetc(FILE *stream); 意為從檔案指標stream指向的檔案中讀取一個字元。 這個函數的傳回值,是返回讀取的一個位元組。如果讀到檔案末尾返回EOF。原型是char *fgets(char *s, int n, FILE *stream); 從流中讀取n-1個字元,除非讀完一行,參數s是來接收字串,如果成功則返回s的指標,否則返回NULL。 fputc()用 法: int fputc(int ch, FILE *stream);