freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

計算機網(wǎng)絡(luò)課程設(shè)計-基于icmptcp的網(wǎng)段端口掃描-c語言編寫(編輯修改稿)

2025-07-23 07:23 本頁面
 

【文章內(nèi)容簡介】 itch(WSAGetLastError()) { case 10060: printf(%s\t%d\tERROR\t\tConnection timed out\n , hostname , i )。 break。 case 10061: printf(%s\t%d\tERROR\t\tConnection refused\n , hostname , i )。 break。 default: printf(%s\t%d\tERROR\tCode:\n,WSAGetLastError())。 break。 } //fflush(stdout)。 } else //連接成功 { printf(%s\t%d\tPORT OPEN\n , hostname ,i)。 //關(guān)閉收發(fā)服務(wù) if( shutdown( sock ,SD_BOTH ) == SOCKET_ERROR ) { printf(Failed to shutdown the connect: %d\n,WSAGetLastError())。 exit(EXIT_FAILURE)。 } } closesocket(sock)。 //關(guān)閉Socket,回收資源 //WSACleanup()。 }利用一個for(。)循環(huán),對確定的起始和終止IP地址的內(nèi)的所有可能存在的主機發(fā)送,請求回顯的ICMP報文,并對返回的ICMP報文進行分析,提取出type和code字段,根據(jù)ICMP報文格式所定義的數(shù)值,對各個主機判斷,并打印信息。 端口掃描for(i = startport 。 i= endport 。 i++) { sock = socket(AF_INET , SOCK_STREAM , IPPROTO_TCP)。 //創(chuàng)建一個Socket if(sock==INVALID_SOCKET) { printf(Create socket failed: %d\n,WSAGetLastError())。 exit(EXIT_FAILURE)。 } //主機字節(jié)序轉(zhuǎn)換為網(wǎng)絡(luò)字節(jié)序 = htons(i)。 //用此Socket連接目的主機,核心代碼 status = connect(sock , (struct sockaddr *)amp。dest , sizeof dest)。 if(status == SOCKET_ERROR) //連接失敗 { switch(WSAGetLastError()) { case 10060: printf(%s\t%d\tERROR\t\tConnection timed out\n , hostname , i )。 break。 case 10061: printf(%s\t%d\tERROR\t\tConnection refused\n , hostname , i )。 break。 default: printf(%s\t%d\tERROR\tCode:\n,WSAGetLastError())。 break。 } //fflush(stdout)。 } else //連接成功 { printf(%s\t%d\tPORT OPEN\n , hostname ,i)。 //關(guān)閉收發(fā)服務(wù) if( shutdown( sock ,SD_BOTH ) == SOCKET_ERROR ) { printf(Failed to shutdown the connect: %d\n,WSAGetLastError())。 exit(EXIT_FAILURE)。 } } closesocket(sock)。 //關(guān)閉Socket,回收資源 //WSACleanup()。 }函數(shù)同樣利用一個for(。)循環(huán)對給定的主機的端口區(qū)間掃描。調(diào)用WSAGetLastError()庫函數(shù)判斷端口是否連接,根據(jù)相應(yīng)的ERROR CODE判斷端口的具體情況。以下是主要的ERROR CODE:WSAETIMEDOUT10060Connection timed out.A connection attempt failed because the connected party did not properly respond after a period of time, or the established connection failed because the connected host has failed to respond.WSAECONNREFUSED10061Connection refused.No connection could be made because the target puter actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running.WSAELOOP10062Cannot translate name.Cannot translate a name.摘自:(v=).aspx 總結(jié)與體會 程序調(diào)試與運行程序主界面IP網(wǎng)段掃描端口掃描 體會通過本次的課程設(shè)計加深了本人對TCP/IP協(xié)議特別是網(wǎng)絡(luò)層協(xié)議,IP首部格式,ICMP首部格式的理解。對Windows網(wǎng)絡(luò)編程也有初步的了解,掌握了基本的套接字程序的編寫。理解原始套接字的運行機制,加深一些協(xié)議字段的理解。編寫過程遇到的困難也不少,但是依靠鉆研精神,逐步對網(wǎng)絡(luò)編程步驟產(chǎn)生了整體的印象,這對以后的學(xué)習(xí)也是一筆寶貴的財富。以前學(xué)習(xí)總是停留在紙面上理論上,雖然貌似一些概念是清楚了,但是這樣的記憶是不長久的。只有通過理論聯(lián)系實際,編寫一些代碼,實現(xiàn)一些功能,才能加強記憶,學(xué)以致用。 參考文獻 參考書目[1] Stevens,Bill Fenner,Andrew . Unix Network Programming Volume1:The Sockets Networking API,Third Edition. Pearson Education,2010[2] Wnthony Jones,Jim Ohlund. Network Programming for Microsoft Windows,Second Press,2002[3] (第四版).電子工業(yè)出版社,2003[4] 周鳴爭,嚴楠,2011 引用網(wǎng)址(v=).aspx(v=).aspx源代碼Scanner,h//IP首部typedef struct ip_hdr{ unsigned char iphVerLen。 // 版本號和頭長度(各占4位) unsigned char ipTOS。 // 服務(wù)類型 unsigned short ipLength。 // 封包總長度,即整個IP報的長度 unsigned short ipID。 // 封包標識,惟一標識發(fā)送的每一個數(shù)據(jù)報 unsigned short ipFlags。 // 標志 unsigned char ipTTL。 // 生存時間,就是TTL unsigned char ipProtocol。 // 協(xié)議,可能是TCP、UDP、ICMP等 unsigned short ipChecksum。 // 校驗和 unsigned long ipSource。 // 源IP地址 unsigned long ipDestination。 // 目標IP地址}IP_HDR,*PIP_HDR。//ICMP首部typedef struct icmp_hdr{ unsigned char icmp_type。 //類型 unsigned char icmp_code。 //代碼 unsigned short icmp_checksum。 //檢驗和 unsigned short icmp_id。 //唯一請求ID,通常使用進程PID unsigned short icmp_sequence。 //序列號 unsigned long icmp_timestamp。 //時間戳} ICMP_HDR,*PICMP_HDR。include include include include include pragma ment(lib,)。include define ICMP_ECHO_REQUEST_TYPE 8 //ICMP請求類型define ICMP_ECHO_REQUEST_CODE 0 //ICMP請求代碼define ICMP_ECHO_REPLY_TYPE 0define ICMP_ECHO_REPLY_CODE 0define ICMP_MINIMUM_HEADER 8struct hostent
點擊復(fù)制文檔內(nèi)容
職業(yè)教育相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1