Αναγν. άρθρου: 828993 - Τελευταία αναθεώρηση: Κυριακή, 29 Μαΐου 2011 - Αναθεώρηση: 4.0

Τρόπος ping σε μια διεύθυνση IP με χρήση των υποδοχών σε Visual Basic.NET

Συμβουλή συστήματοςΑυτό το άρθρο ισχύει για διαφορετικό λειτουργικό σύστημα από αυτό που χρησιμοποιείτε. Το περιεχόμενο του άρθρου που ενδέχεται να μην σας αφορά έχει απενεργοποιηθεί.

Σε αυτήν τη σελίδα

Ανάπτυξη όλων | Σύμπτυξη όλων

Περίληψη

Αυτό το άρθρο βήμα προς βήμα περιγράφει τον τρόπο χρήσης των υποδοχών σε Η Microsoft Visual Basic.NET να πραγματοποιήσετε λειτουργία ping σε μια διεύθυνση πρωτοκόλλου Internet (IP). Η εντολή PING η εντολή χρησιμοποιεί Internet Control Message Protocol (ICMP) για να ελέγξετε μια σύνδεση δικτύου. Υπολογίζεται και εμφανίζεται το χρόνο απόκρισης για να εκτελέσετε λειτουργία ping σε μια συγκεκριμένη διεύθυνση IP. Αυτό το άρθρο χρησιμοποιεί το System.NET.Sockets API της Visual Basic.NET να πραγματοποιήσετε λειτουργία ping σε μια διεύθυνση IP.

Απαιτήσεις

Αυτό το άρθρο προϋποθέτει ότι είστε εξοικειωμένοι με τα ακόλουθα θέματα:
  • Προγραμματισμός με τη Visual Basic.NET
  • Υποδοχές
Η ακόλουθη λίστα περιγράφει το συνιστώμενο υλικό, λογισμικό, υποδομή δικτύου και service pack που χρειάζεστε:
  • Microsoft Windows 2000, τα Microsoft Windows XP ή Microsoft Windows Server 2003
  • Η Microsoft Visual Basic.NET

Δηλώνετε μια δομή πακέτων ICMP

ICMP υποστηρίζει πακέτα που περιέχουν μηνύματα σφάλματος, μηνύματα ελέγχου και πληροφοριακών μηνυμάτων. Η εντολή PING η εντολή χρησιμοποιεί ICMP για να ελέγξετε μια σύνδεση δικτύου. Χρησιμοποιήστε τον παρακάτω κώδικα στο Δηλώστε τη δομή ενός πακέτου ICMP και να δηλώσετε μια μέθοδο για τον υπολογισμό ο συνολικός αριθμός byte σε ένα πακέτο:
   Structure IcmpPacket
#Region "PUBLIC MEMBER VARIABLES"
      Dim type_message As Byte                ' Type of message.
      Dim subCode_type As Byte                ' Type of sub-code.
      Dim complement_checkSum As UInt16       ' One's complement checksum for the structure.
      Dim identifier As UInt16                ' Identifier.
      Dim sequenceNumber As UInt16            ' Sequence number.
      Dim data() As Byte                      ' Data.
#End Region


#Region "PUBLIC MEMBER METHODS"
      Public Sub Initialize(ByVal type As Byte, ByVal subCode As Byte, ByVal payload() As Byte)
         Dim index As Integer
         Dim buffer_icmpPacket() As Byte
         Dim cksumBuffer() As UInt16
         Dim icmpHeaderBufferIndex As Int32 = 0
         Me.type_message = type
         Me.subCode_type = subCode
         complement_checkSum = UInt16.Parse("0")
         identifier = UInt16.Parse("45")
         sequenceNumber = UInt16.Parse("0")
         Data = payload

         ' Declare a variable to store the total packet size.
         ' Call the Serialize method to count the total number of bytes in the packet.
         buffer_icmpPacket = Serialize()

         ' Resize a UInt16 array to half the size of the packet.
         ReDim cksumBuffer((buffer_icmpPacket.Length() \ 2) - 1)

         ' Initialize the UInt16 array.
         For index = 0 To (cksumBuffer.Length() - 1)
            cksumBuffer(index) = BitConverter.ToUInt16(buffer_icmpPacket, icmpHeaderBufferIndex)
            icmpHeaderBufferIndex += 2
         Next index

         'Call a method that returns a checksum.
         complement_checkSum = MCheckSum.Calculate(cksumBuffer, cksumBuffer.Length())
      End Sub

      Public Function Size() As Integer
         Return (8 + Data.Length())
      End Function

      ' The Serialize method converts the packet to a byte array to calculate the total size.
      Public Function Serialize() As Byte()
         Dim b_seq() As Byte = BitConverter.GetBytes(sequenceNumber)
         Dim b_cksum() As Byte = BitConverter.GetBytes(complement_checkSum)
         Dim b_id() As Byte = BitConverter.GetBytes(identifier)
         Dim index As Int32 = 0
         Dim buffer() As Byte
         ReDim buffer(Size() - 1)

         ' Serialize the structure into the array.
         buffer(0) = type_message
         buffer(1) = subCode_type
         index += 2
         Array.Copy(b_cksum, 0, buffer, index, 2)
         index += 2
         Array.Copy(b_id, 0, buffer, index, 2)
         index += 2
         Array.Copy(b_seq, 0, buffer, index, 2)
         index += 2

         ' Copy the data.
         If (Data.Length() > 0) Then
            Array.Copy(Data, 0, buffer, index, Data.Length())
         End If
         Return buffer
      End Function
#End Region
   End Structure

Ορισμός της κλάσης CPing

Το CPing η κλάση περιέχει μεθόδους για να αποδεχτείτε το όνομα κεντρικού υπολογιστή ή το IP διεύθυνση διακομιστή ως είσοδο, να πραγματοποιήσετε λειτουργία ping το όνομα κεντρικού υπολογιστή ή τη διεύθυνση IP, και Για να εμφανίσετε το χρόνο απόκρισης.
   ' The CPing class.
   Public Class CPing
#Region "MEMBER CONSTANTS"
      Private Const DEFAULT_TIMEOUT As Integer = 1000
      Private Const SOCKET_ERROR As Integer = -1
      Private Const PING_ERROR As Integer = -1
      Private Const ICMP_ECHO As Integer = 8
      Private Const DATA_SIZE As Integer = 32
      Private Const RECV_SIZE As Integer = 128
#End Region

#Region "MEMBER VARIABLES"
      Private _open As Boolean = False
      Private _initialized As Boolean
      Private _recvBuffer() As Byte
      Private _packet As IcmpPacket
      Private _hostName As String
      Private _server As EndPoint
      Private _local As EndPoint
      Private _socket As Socket

#End Region

#Region "CONSTRUCTORS & FINALIZER"
      Public Sub New(ByVal hostName As String)
         Me.HostName() = hostName
         ReDim _recvBuffer(RECV_SIZE - 1)
      End Sub

      Public Sub New()
         ' Set the default host name to the local host.
         Me.HostName() = Dns.GetHostName()
         ReDim _recvBuffer(RECV_SIZE - 1)
      End Sub

      Private Overloads Sub finalize()
         ' Make sure that you close the socket.
         Me.Close()
         Erase _recvBuffer
      End Sub
#End Region

#Region "MEMBER METHODS"
      ' Get and set the current host name.
      Public Property HostName() As String
         Get
            Return _hostName
         End Get
         Set(ByVal Value As String)
            _hostName = Value
            ' If the CPing object is already open, close it and then reopen it by using a new host name.
            If (_open) Then
               Me.Close()
               Me.Open()
            End If
         End Set
      End Property

      ' Get the state (open or closed).
      Public ReadOnly Property IsOpen() As Boolean
         Get
            Return _open
         End Get
      End Property

      ' Create a socket to host remote end points and local end points.
      Public Function Open() As Boolean
         Dim payload() As Byte

         If (Not _open) Then
            Try
               ' Initialize the packet.
               ReDim payload(DATA_SIZE)
               _packet.Initialize(ICMP_ECHO, 0, payload)

               ' Initialize an ICMP socket.
               _socket = New Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp)

               ' Set the server end point.
               _server = New IPEndPoint(Dns.GetHostByName(_hostName).AddressList(0), 0)

               ' Set the receiving end point as your client computer.
               _local = New IPEndPoint(Dns.GetHostByName(Dns.GetHostName()).AddressList(0), 0)
               _open = True
            Catch
               Return False
            End Try
         End If
         Return True
      End Function

      ' Destroy the socket and the end points (if necessary).
      Public Function Close() As Boolean
         If (_open) Then
            _socket.Close()
            _socket = Nothing
            _server = Nothing
            _local = Nothing
            _open = False
         End If
         Return True
      End Function

      ' Perform a PING operation.
      Public Overloads Function Ping() As Integer
         Return Ping(DEFAULT_TIMEOUT)
      End Function

      ' The Ping method performs a PING operation.
      Public Overloads Function Ping(ByVal timeOutMilliSeconds As Integer) As Integer

         ' Initialize the time-out value.
         Dim timeOut As Integer = timeOutMilliSeconds + Environment.TickCount()

         ' Send the packet.
         If (SOCKET_ERROR = _socket.SendTo(_packet.Serialize(), _packet.Size(), 0, _server)) Then
            Return PING_ERROR
         End If

         ' Use the following loop to check the response time until you receive a time-out.
         Do
            ' Poll the read buffer every millisecond.
            ' If data exists, read the data and return the round-trip time.
            If (_socket.Poll(1000, SelectMode.SelectRead)) Then
               _socket.ReceiveFrom(_recvBuffer, RECV_SIZE, 0, _local)
               Return (timeOutMilliSeconds - (timeOut - Environment.TickCount()))
            ElseIf (Environment.TickCount() >= timeOut) Then
               Return PING_ERROR
            End If
         Loop While (True)
      End Function
#End Region
   End Class

Υπολογίζει την τιμή αθροίσματος ελέγχου

Ο κώδικας που ακολουθεί περιέχει μια Υπολογισμός μέθοδος υπολογίζει την τιμή αθροίσματος ελέγχου. Αυτός ο κωδικός περιλαμβάνει επίσης ενώσεις που το Υπολογισμός χρησιμοποιεί τη μέθοδο.
#Region "MEMBER METHODS"
      <StructLayout(LayoutKind.Explicit)> _
                 Structure UNION_INT16
         <FieldOffset(0)> Dim lsb As Byte      ' Least significant byte
         <FieldOffset(1)> Dim msb As Byte      ' Most significant byte
         <FieldOffset(0)> Dim w16 As Short
      End Structure

      <StructLayout(LayoutKind.Explicit)> _
      Structure UNION_INT32
         <FieldOffset(0)> Dim lsw As UNION_INT16     ' Most significant word
         <FieldOffset(2)> Dim msw As UNION_INT16     ' Least significant word
         <FieldOffset(0)> Dim w32 As Integer
      End Structure

      ' The Calculate method calculates the checksum value.
      Public Function Calculate(ByRef buffer() As UInt16, ByVal size As Int32) As UInt16
         Dim counter As Int32 = 0
         Dim cksum32 As UNION_INT32
         Do While (size > 0)
            cksum32.w32 += Convert.ToInt32(buffer(counter))
            counter += 1
            size -= 1
         Loop

         cksum32.w32 = cksum32.msw.w16 + cksum32.lsw.w16 + cksum32.msw.w16
         Return Convert.ToUInt16(cksum32.lsw.w16 Xor &HFFFF)
      End Function
#End Region

Υλοποιεί το περιβάλλον εργασίας χρήστη

Ο κώδικας που ακολουθεί υλοποιεί το περιβάλλον εργασίας χρήστη. Αυτός ο κωδικός προσδιορίζει Αν το όνομα κεντρικού υπολογιστή ή η IP διεύθυνση που πληκτρολογεί ο χρήστης είναι κενή, και στη συνέχεια ειδοποιεί το χρήστη να πληκτρολογήσει ένα όνομα κεντρικού υπολογιστή ή διεύθυνση IP στην καθορισμένη μορφή. Αφού ο χρήστης πληκτρολογήσει ένα όνομα κεντρικού υπολογιστή ή διεύθυνση IP, η εφαρμογή δημιουργεί υποδοχή σύνδεσης με την αντίστοιχη διεύθυνση IP (Εάν αυτή η διεύθυνση του ίδιο δίκτυο) και στη συνέχεια, η εφαρμογή αποστέλλει ένα πακέτο δεδομένων χρησιμοποιώντας ICMP. Μετά την εφαρμογή υπολογίζει χρόνος (σε χιλιοστά του δευτερολέπτου) για αποστολή και λήψη δεδομένων το πακέτο και η εφαρμογή εμφανίζει αυτή την τιμή. Εάν δεν είναι στο όνομα κεντρικού υπολογιστή ή τη διεύθυνση IP στο ίδιο δίκτυο ή αν ο χρήστης πληκτρολογήσει μια έγκυρη διεύθυνση IP ή κεντρικός υπολογιστής δεν είναι έγκυρη όνομα, η εφαρμογή εμφανίζει ένα μήνυμα.
Sub Main()
   Dim Packet As New ICMP_Packet.CPing()
   Dim retValue

   Console.WriteLine("Enter the IP address or the host name to ping: ")

   ' Accept a host name or an IP address.
   Packet.HostName = Trim(Console.ReadLine())

   ' Determine whether the user has typed only spaces instead of a host name or an IP address.
   If Packet.HostName = "" Then
      Console.WriteLine("Please enter an IP address (in the N.N.N.N format) or a host name")
   Else
      ' Determine whether you can establish a socket connection to the IP address.
      If Packet.Open Then
         ' Establish a socket connection, and then send a packet using ICMP.
         retValue = Packet.Ping
         If retValue <> -1 Then
            ' Display the response time in milliseconds.
            Console.WriteLine("Approximate response time : " & retValue)
         Else
            Console.WriteLine("Host Unreachable")
         End If
      Else
         Console.WriteLine("No host found")
      End If
      
      Packet.Close()

   End If

   Console.WriteLine("Press ENTER to quit.")
   Console.ReadLine()

End Sub

Δημιουργία μιας εφαρμογής κονσόλας

  1. Ξεκινήστε το Microsoft Visual Studio.NET.
  2. Από το Το αρχείο μενού, σημείοΝέα, και στη συνέχεια κάντε κλικ στο κουμπί Έργο. Το Νέα Έργο εμφανίζεται το παράθυρο διαλόγου.
  3. Στην περιοχή Τύποι έργου, κάντε κλικ στο κουμπί Οπτική Βασικά έργα.
  4. Στην περιοχή Πρότυπα, κάντε κλικ στο κουμπί Κονσόλα Εφαρμογή.
  5. Με το Όνομα πλαίσιο, πληκτρολογήστεMyConsoleApplication.

    Σημείωση MyConsoleApplication είναι ένα δείγμα της Visual Basic.NET εφαρμογή.
  6. Με το Θέση Πληκτρολογήστε το θέση όπου θέλετε να αποθηκεύσετε το έργο MyConsoleApplication και στη συνέχεια κάντε κλικ στο κουμπίOK.

    Από προεπιλογή, δημιουργείται το αρχείο Module1.vb.
  7. Στο αρχείο Module1.vb, να αντικαταστήσετε τον υπάρχοντα κώδικα με το ακόλουθο κώδικα:
    Imports System.Net.Sockets
    Imports System.Net
    Imports System
    Imports System.Runtime.InteropServices
    
    Namespace ICMP_Packet
    
       ' Define the structure of an ICMP packet.
       ' This structure contains packet information.
       Structure IcmpPacket
    #Region "PUBLIC MEMBER VARIABLES"
          Dim type_message As Byte                ' type of message
          Dim subCode_type As Byte                ' type of sub-code
          Dim complement_checkSum As UInt16       ' one's complement checksum for the structure
          Dim identifier As UInt16                ' identifier
          Dim sequenceNumber As UInt16            ' sequence number  
          Dim data() As Byte                      ' data
    #End Region
    
    
    #Region "PUBLIC MEMBER METHODS"
          Public Sub Initialize(ByVal type As Byte, ByVal subCode As Byte, ByVal payload() As Byte)
             Dim index As Integer
             Dim buffer_icmpPacket() As Byte
             Dim cksumBuffer() As UInt16
             Dim icmpHeaderBufferIndex As Int32 = 0
             Me.type_message = type
             Me.subCode_type = subCode
             complement_checkSum = UInt16.Parse("0")
             identifier = UInt16.Parse("45")
             sequenceNumber = UInt16.Parse("0")
             Data = payload
    
             ' Declare a variable to store the total packet size.
             ' Call the Serialize method to count the total number of bytes in the packet.
             buffer_icmpPacket = Serialize()
    
             ' Resize a UInt16 array to half the size of the packet.
             ReDim cksumBuffer((buffer_icmpPacket.Length() \ 2) - 1)
    
             ' Initialize the UInt16 array.
             For index = 0 To (cksumBuffer.Length() - 1)
                cksumBuffer(index) = BitConverter.ToUInt16(buffer_icmpPacket, icmpHeaderBufferIndex)
                icmpHeaderBufferIndex += 2
             Next index
    
             'Call a method that returns a checksum.
             complement_checkSum = MCheckSum.Calculate(cksumBuffer, cksumBuffer.Length())
          End Sub
    
          Public Function Size() As Integer
             Return (8 + Data.Length())
          End Function
    
          ' The Serialize method converts the packet to a byte array to calculate the total size.
          Public Function Serialize() As Byte()
             Dim b_seq() As Byte = BitConverter.GetBytes(sequenceNumber)
             Dim b_cksum() As Byte = BitConverter.GetBytes(complement_checkSum)
             Dim b_id() As Byte = BitConverter.GetBytes(identifier)
             Dim index As Int32 = 0
             Dim buffer() As Byte
             ReDim buffer(Size() - 1)
    
             ' Serialize the structure into the array.
             buffer(0) = type_message
             buffer(1) = subCode_type
             index += 2
             Array.Copy(b_cksum, 0, buffer, index, 2)
             index += 2
             Array.Copy(b_id, 0, buffer, index, 2)
             index += 2
             Array.Copy(b_seq, 0, buffer, index, 2)
             index += 2
    
             ' Copy the data.
             If (Data.Length() > 0) Then
                Array.Copy(Data, 0, buffer, index, Data.Length())
             End If
             Return buffer
          End Function
    #End Region
       End Structure
    
       ' The CPing class.
       Public Class CPing
    #Region "MEMBER CONSTANTS"
          Private Const DEFAULT_TIMEOUT As Integer = 1000
          Private Const SOCKET_ERROR As Integer = -1
          Private Const PING_ERROR As Integer = -1
          Private Const ICMP_ECHO As Integer = 8
          Private Const DATA_SIZE As Integer = 32
          Private Const RECV_SIZE As Integer = 128
    #End Region
    
    #Region "MEMBER VARIABLES"
          Private _open As Boolean = False
          Private _initialized As Boolean
          Private _recvBuffer() As Byte
          Private _packet As IcmpPacket
          Private _hostName As String
          Private _server As EndPoint
          Private _local As EndPoint
          Private _socket As Socket
    
    #End Region
    
    #Region "CONSTRUCTORS & FINALIZER"
          Public Sub New(ByVal hostName As String)
             Me.HostName() = hostName
             ReDim _recvBuffer(RECV_SIZE - 1)
          End Sub
    
          Public Sub New()
             ' Set the default host name to the local host.
             Me.HostName() = Dns.GetHostName()
             ReDim _recvBuffer(RECV_SIZE - 1)
          End Sub
    
          Private Overloads Sub finalize()
             ' Ensure that you close the socket.
             Me.Close()
             Erase _recvBuffer
          End Sub
    #End Region
    
    #Region "MEMBER METHODS"
          ' Get and set the current host name.
          Public Property HostName() As String
             Get
                Return _hostName
             End Get
             Set(ByVal Value As String)
                _hostName = Value
                ' If the CPing object is already open, close it and then reopen it by using a new host name.
                If (_open) Then
                   Me.Close()
                   Me.Open()
                End If
             End Set
          End Property
    
          ' Get the state (open or closed).
          Public ReadOnly Property IsOpen() As Boolean
             Get
                Return _open
             End Get
          End Property
    
          ' Create a socket to host remote end points and local end points.
          Public Function Open() As Boolean
             Dim payload() As Byte
    
             If (Not _open) Then
                Try
                   ' Initialize the packet.
                   ReDim payload(DATA_SIZE)
                   _packet.Initialize(ICMP_ECHO, 0, payload)
    
                   ' Initialize an ICMP socket.
                   _socket = New Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp)
    
                   ' Set the server end point.
                   _server = New IPEndPoint(Dns.GetHostByName(_hostName).AddressList(0), 0)
    
                   ' Set the receiving end point as your client computer.
                   _local = New IPEndPoint(Dns.GetHostByName(Dns.GetHostName()).AddressList(0), 0)
                   _open = True
                Catch
                   Return False
                End Try
             End If
             Return True
          End Function
    
          ' Destroy the socket and end points (if necessary).
          Public Function Close() As Boolean
             If (_open) Then
                _socket.Close()
                _socket = Nothing
                _server = Nothing
                _local = Nothing
                _open = False
             End If
             Return True
          End Function
    
          ' Perform a PING operation.
          Public Overloads Function Ping() As Integer
             Return Ping(DEFAULT_TIMEOUT)
          End Function
    
          ' The Ping method performs a PING operation.
          Public Overloads Function Ping(ByVal timeOutMilliSeconds As Integer) As Integer
    
             ' Initialize the time-out value.
             Dim timeOut As Integer = timeOutMilliSeconds + Environment.TickCount()
    
             ' Send the packet.
             If (SOCKET_ERROR = _socket.SendTo(_packet.Serialize(), _packet.Size(), 0, _server)) Then
                Return PING_ERROR
             End If
    
             ' Use the following loop to check the response time until you receive a time-out.
             Do
                ' Poll the read buffer every millisecond.
                ' If data exists, read the data and return the round-trip time.
                If (_socket.Poll(1000, SelectMode.SelectRead)) Then
                   _socket.ReceiveFrom(_recvBuffer, RECV_SIZE, 0, _local)
                   Return (timeOutMilliSeconds - (timeOut - Environment.TickCount()))
                ElseIf (Environment.TickCount() >= timeOut) Then
                   Return PING_ERROR
                End If
             Loop While (True)
          End Function
    #End Region
       End Class
    
       ' The MCheckSum module contains the static Calculate method.
       Module MCheckSum
    #Region "MEMBER METHODS"
          <StructLayout(LayoutKind.Explicit)> _
                     Structure UNION_INT16
             <FieldOffset(0)> Dim lsb As Byte      ' Least significant byte
             <FieldOffset(1)> Dim msb As Byte      ' Most significant byte
             <FieldOffset(0)> Dim w16 As Short
          End Structure
    
          <StructLayout(LayoutKind.Explicit)> _
          Structure UNION_INT32
             <FieldOffset(0)> Dim lsw As UNION_INT16     ' Most significant word
             <FieldOffset(2)> Dim msw As UNION_INT16     ' Least significant word
             <FieldOffset(0)> Dim w32 As Integer
          End Structure
    
          ' The Calculate method calculates the checksum value.
          Public Function Calculate(ByRef buffer() As UInt16, ByVal size As Int32) As UInt16
             Dim counter As Int32 = 0
             Dim cksum32 As UNION_INT32
             Do While (size > 0)
                cksum32.w32 += Convert.ToInt32(buffer(counter))
                counter += 1
                size -= 1
             Loop
    
             cksum32.w32 = cksum32.msw.w16 + cksum32.lsw.w16 + cksum32.msw.w16
             Return Convert.ToUInt16(cksum32.lsw.w16 Xor &HFFFF)
          End Function
    #End Region
    
          Sub Main()
             Dim Packet As New ICMP_Packet.CPing()
             Dim retValue
    
             Console.WriteLine("Enter the IP address or the host name to ping: ")
    
             ' Accept a host name or an IP address.
             Packet.HostName = Trim(Console.ReadLine())
    
             ' Determine whether the user has typed only spaces instead of a host name or an IP address.
             If Packet.HostName = "" Then
                Console.WriteLine("Please enter an IP address (in the N.N.N.N format) or a host name")
             Else
                ' Determine whether you can establish a socket connection to the IP address.
                If Packet.Open Then
                   ' Establish a socket connection, and then send a packet by using ICMP.
                   retValue = Packet.Ping
                   If retValue <> -1 Then
                      ' Display the response time in milliseconds.
                      Console.WriteLine("Approximate response time : " & retValue)
                   Else
                      Console.WriteLine("Host Unreachable")
                   End If
                Else
                   Console.WriteLine("No host found")
                End If
                
                Packet.Close()
    
             End If
    
             Console.WriteLine("Press ENTER to quit.")
             Console.ReadLine()
    
          End Sub
       End Module
    
    End Namespace
  8. Στην Εξερεύνηση λύση, κάντε κλικ στην επιλογή τουMyConsoleApplication το έργο.
  9. Από το Έργο μενού, κάντε κλικ στο κουμπίΙδιότητες.
  10. Με το Σελίδες ιδιοτήτων MyConsoleApplicationστο παράθυρο διαλόγου επιλογή Sub Main από το Εκκίνηση αντικείμενο πλαίσιο αναπτυσσόμενης λίστας και στη συνέχεια κάντε κλικOK.
  11. Από το Ο εντοπισμός σφαλμάτων μενού, κάντε κλικ στο κουμπίΈναρξη.
  12. Στη γραμμή εντολών που εμφανίζεται, πληκτρολογήστε ένα όνομα κεντρικού υπολογιστή ή μια Διεύθυνση IP και κατόπιν πιέστε το πλήκτρο ENTER.

Αναφορές

Για περισσότερες πληροφορίες, επισκεφθείτε την ακόλουθη Microsoft Τοποθεσίες Web Developer Network (MSDN):
.aspx http://msdn2.Microsoft.com/en-us/library/System.NET.Sockets (vs.71) (http://msdn2.microsoft.com/en-us/library/system.net.sockets(vs.71).aspx)

.aspx http://msdn2.Microsoft.com/en-us/library/b6xa24z5 (vs.71) (http://msdn2.microsoft.com/en-us/library/b6xa24z5(vs.71).aspx)

.aspx http://msdn2.Microsoft.com/en-us/library/System.NET.Sockets.Socket (vs.71) (http://msdn2.microsoft.com/en-us/library/system.net.sockets.socket(vs.71).aspx)
Για πρόσθετες πληροφορίες, κάντε κλικ στον αριθμό του άρθρου παρακάτω, για να προβάλετε το άρθρο της Γνωσιακής Βάσης της Microsoft:
300197  (http://support.microsoft.com/kb/300197/ ) ΠΏΣ ΠΡΟΣ: Ping σε μια διεύθυνση IP με τη Visual Basic, χρησιμοποιώντας το ICMP

Οι πληροφορίες σε αυτό το άρθρο ισχύουν για:
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
Λέξεις-κλειδιά: 
kbnetwork kbhowtomaster kbwinsock kbmt KB828993 KbMtel
Μηχανικά μεταφρασμένοΜηχανικά μεταφρασμένο
ΣΗΜΑΝΤΙΚΟ: Αυτό το άρθρο είναι προϊόν λογισμικού μηχανικής μετάφρασης της Microsoft και όχι ανθρώπινης μετάφρασης. Η Microsoft σάς προσφέρει άρθρα που είναι προϊόντα ανθρώπινης αλλά και μηχανικής μετάφρασης έτσι ώστε να έχετε πρόσβαση σε όλα τα άρθρα της Γνωσιακής Βάσης μας στη δική σας γλώσσα. Ωστόσο, ένα άρθρο που έχει προκύψει από μηχανική μετάφραση δεν είναι πάντα άριστης ποιότητας. Ενδέχεται να περιέχει λεξιλογικά, συντακτικά ή γραμματικά λάθη, όπως ακριβώς τα λάθη που θα έκανε ένας μη φυσικός ομιλητής επιχειρώντας να μιλήσει τη γλώσσα σας. Η Microsoft δεν φέρει καμία ευθύνη για τυχόν ανακρίβειες, σφάλματα ή ζημίες που προκύψουν λόγω τυχόν παρερμηνειών στη μετάφραση του περιεχομένου ή χρήσης του από τους πελάτες της. Επίσης, η Microsoft πραγματοποιεί συχνά ενημερώσεις στο λογισμικό μηχανικής μετάφρασης.
Η αγγλική έκδοση αυτού του άρθρου είναι η ακόλουθη:828993  (http://support.microsoft.com/kb/828993/en-us/ )