【正文】
multi thread 20 。 Send and receive text messages。 參考文獻(xiàn) [1]趙敏哲 .64 位 Linux 操作系統(tǒng)與應(yīng)用實(shí)例 [M].北京:機(jī)械工業(yè)出版社 ,20xx. [2]龐麗萍 .操作系統(tǒng)原理 (3 版 )[M].武漢:華中科技大學(xué)出版社 ,20xx. [3]張饒學(xué) .Linux 網(wǎng)絡(luò)編程 [M].北京 :清華大學(xué)出版社 ,20xx. [4]金鐘夫 ,杜剛 .淺析 socket 網(wǎng)絡(luò)編程 [J].微計(jì)算機(jī)信息 ,20xx,32,8789. [5]鄭燕飛 ,余海燕 .linux 的多線程機(jī)制探討與實(shí)踐 [J].計(jì)算機(jī)應(yīng)用 ., 21(1):8182 [6]王群 ,許中萬 .Linux 優(yōu)勢(shì)分析 [J].計(jì)算機(jī)與現(xiàn)代化, 20xx(10):78. [7]任泰明著 . TCP/IP 協(xié)議與網(wǎng)絡(luò)編程 [M]. 西安 :西安電子科技大學(xué)出版社 . 20xx. [8]謝希仁 . 計(jì)算機(jī)網(wǎng)絡(luò)( 5 版) [M]. 西安 :電子工業(yè)出版社 . [9]陳劍 .基于 socket 的進(jìn)程間通信平臺(tái)的設(shè)計(jì)與實(shí)現(xiàn) [D].東北大學(xué) .20xx. [10]趙穎 ,韓秀梅,馬宏騫 .linux 下的 c 語言編程 [J].遼林工學(xué)院學(xué)報(bào) . [11]陳波 ,石旭剛,史故臣 .嵌入式 c 語言在系統(tǒng)開發(fā)中的代碼優(yōu)化 [J].計(jì)算機(jī)時(shí)代 .20xx,( 11): 5556. 19 英文摘要 Design and implementation of SMS Linux transceiver system based on C Student majoring in puter science and technology Qin ZhangYang Tutor Liu Bin Abstract: The messaging system is Linux under the C language, based on multithreading, GMS protocol, select non blocking, using TCP connection and transmission mode and work programming. I want to do is to simulate the mobile phone short message form to send and receive SMS, a server to manage multiple service level to two, then the two stage management server to multiple clients, through the design of two layer load balancing server to realize the server, so the same number section number can be achieved the client message through the number of segments of two level servers to send and receive information, different numbers of transmit information through a mail client server, through the implementation of this system can be used to learn the knowledge link, consolidate and enhance the ability of their own programming. Keywords: C/S。幫助我解決一些 自己不能夠很好解決的問題,這樣我的畢業(yè)設(shè)計(jì)才能順利的完成。轉(zhuǎn)眼間大學(xué)的四年就要結(jié)束了,能讓我的大學(xué)畫上完美的句號(hào)和畢業(yè)答辯能夠取得圓滿的成功。因?yàn)樽约褐R(shí)體系還不是特別的完整,編程能力也沒有特別的強(qiáng),所以系統(tǒng)并沒有那么的完善,所以在以后的工作中還是要繼續(xù)的學(xué)習(xí),提升自己的編程能力和分析問題的能力。在這幾個(gè)月當(dāng)中多是利用晚上的時(shí)間去編寫程序的,在編寫程序的過程中也遇到很多的苦難,用對(duì)一些知識(shí)還不是很熟,用起來會(huì)出現(xiàn)一些錯(cuò)誤,但是最終通過網(wǎng)絡(luò),通過指導(dǎo)老師還是把這些問題給解決了。另一方面測(cè)試可以檢測(cè)出系統(tǒng)中的一些 bug,有些 bug 只有通過大量的重復(fù)測(cè)試才可以顯示出來的,然 后在解掉 bug,優(yōu)化系統(tǒng)的功能,讓用戶能夠有更好的用戶體驗(yàn)。 圖 15 二級(jí)服務(wù)器測(cè)試圖 如圖 15 所示是大量的 client 端連接到二級(jí)服務(wù)器上的,然后在測(cè)試二級(jí)服務(wù)器能否把信息的傳遞,在測(cè)試的過程中由于電腦性能的緣故,在信息發(fā)送的時(shí)候會(huì)出現(xiàn)一些的卡頓,但是信息還是可以正常的發(fā)送的。所以 要通過測(cè)試 ,盡 量的減少程序中 的錯(cuò)誤, 從而 達(dá)到 系統(tǒng)穩(wěn)定運(yùn)作的目的 ,使 短信收發(fā)系統(tǒng)工作不會(huì)收到影響 。如果 程序員 不能及時(shí) 的 將 這些錯(cuò)誤 找出 來 并修改, 有可能 會(huì) 造成系統(tǒng)無法正常工作造 成 一些損失 。 } 測(cè)試 測(cè)試的目的 就是為了 是尋找 程序中的 錯(cuò)誤, 而且是 盡可能 的去 找出 程序中 的盡可能多 錯(cuò)誤 [11]。 printf(%d\n,leng) printf(num: %s\ntime: %smessage: %s\n,arr_msg[j].num,arr_msg[j].time,arr_msg[j].message)。j++) { leng = j + 1。 } for(j = 0。 i++。 fread(amp。 } while(1) { memset(amp。 if(NULL == fp) { printf(open fail !)。 char chose。 FILE *fp = NULL。 int j。 } } 圖 13 收信息運(yùn)行圖 16 如圖 13 所示是查看收信箱的信息,其中調(diào)用了 recv_print_(argv[4])函數(shù)把儲(chǔ)存在文件中的短信信息多打印在終端上,可以顯示短信的發(fā)送者號(hào)碼和發(fā)送時(shí)間和具體的短信內(nèi)容。 printf(\n***send to %s client from %s client siccess****\n,ss,)。 send(all_cli[i].fd,amp。 strcpy(,)。 strcpy(ss,)。i geshu。send_msg,sizeof(deliver),0)。 int i。 } } 130 二級(jí)服務(wù)器接收到一級(jí)服務(wù)器的信息時(shí),就會(huì)通過號(hào)碼的匹配吧信息發(fā)給 13011 這個(gè)客戶端,實(shí)現(xiàn)了夸號(hào)碼段轉(zhuǎn)發(fā)。i++) { if(0 == strncmp(,[i].num,3)) 15 { send([i].fd,amp。 } for(i = 0。 if(n = 0) { printf(sonser %s exit\n,)。 n = recv(,amp。 memset(amp。send_msg,sizeof(deliver),0)。one_scli,sizeof(msg),0)。 printf(\n***zhuan fa to %s server ****\n,)。 msg one_scli。send_msg,sizeof(submit),0)。 13111client send()函數(shù)把信息發(fā)給 131 二級(jí)服務(wù)器。 buf = NULL。 //head = msg_insert(head,buf)。recv_msg,buf)。recv_msg,argv[4])。recv_msg)。recv_msg,sizeof(deliver))。recv_msg,0,sizeof(deliver))。 buf = (MSG *)malloc(sizeof(MSG))。 MSG *buf = NULL。recv_msg)函數(shù),把接收到的信息打印到終端上去,再調(diào)用函數(shù) recv_save_(amp。 } 圖 10 客戶端運(yùn)行圖 如圖 10 所示是在 client 端發(fā)送信息時(shí)提示用戶是否發(fā)送信息,不發(fā)送的話系統(tǒng)就會(huì)調(diào)用 staff_save_(cli_num,cli_msg,argv[6])函數(shù)把信息保存在草稿箱當(dāng)中。 case 5: return。 staff_print_(argv[6])。 break。 case 3: printf(\n*****************finishmessage***************\n\n)。 recv_print_(