Teach you to write the "port scanner" VB article of network communication program source code (4)

xiaoxiao2021-03-06  41

* Angel * at 2001.9.25

Http://netis.126.com (please indicate the source)

===========

** This article will introduce VB to use the Winsock control, write simple web applications **

** written to all beginners who are interested in networking! **

==================================

This is a simple "port scan program" source code

I. Control Description:

Window: frMscan

** * TEXTBOX: TXTLOWERBOUND in FRMSCAN ** * TxtLowerBound TXTUPPERBOUND (End Port) TXTMAXCONNECTIONS (Number of connections) LStopenports (Listing Open Port) * CommandButton: cmdscan Scan) CMDStop CMDClearList (List of open port) * Winsock: WSKSocket (TCP protocol) * Timer: Timtimer (timeout setting) *************************** ***

2. Source code: =========================================

Option Explicitdim LNGNEXTPORT As Long

Private subdclearList_click () me.lstopenports.clearend Sub

Private Sub cmdScan_Click () Dim intI As Integer lngNextPort = Val (Me.txtLowerBound) For intI = 1 To Val (Me.txtMaxConnections) Load Me.wskSocket (intI) lngNextPort = lngNextPort 1 Me.wskSocket (intI) .Connect Me. TXTIP, LNGNEXTPORT Next INTIEND SUB

Private Sub cmdStop_Click () Dim intI As Integer For intI = 1 To Val (Me.txtMaxConnections) Me.wskSocket (intI) .Close Unload Me.wskSocket (intI) Next intIEnd SubPrivate Sub timTimer_Timer () Me.sbMain.Panels (1) .Text = "Current Port:" STR (LNGNEXTPORT) END SUB

Private sub wsksocket_connect (index as integer) me.lstopenports.additem "port:" Str (me.wsksocket (index) .remoteport) TRY_NEXT_PORT (INDEX) End Sub

Private Sub wskSocket_Error (Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean) Try_Next_Port (Index) End Sub

Private Sub Try_Next_Port (Index As Integer) Me.wskSocket (Index) .Close If lngNextPort

==============================================================================================================================================

The code is actually very simple, I believe everyone is easy to understand! I didn't have time recently, so I wrote it later for the last UPD agreement. However, I will still post some program source code to give you a reference.

-------------------------------------------------- Next, I will post some programs source code for your reference! If you are interested in http://netis.126.com

All rights reserved for CNINF.COM, please indicate the source, thank you! Explaced angel ...

................................................ .. Repost .......................................

转载请注明原文地址:https://www.9cbs.com/read-56897.html

New Post(0)