文章編號: 828993 - 上次校閱: 2007年4月19日 - 版次: 1.3

如何使用 Visual Basic.NET 中的通訊端 Ping 的 IP 位址

系統提示本文適用於您使用的作業系統之外的作業系統。與您不相關的文章內容已停用。

在此頁中

全部展開 | 全部摺疊

結論

本文將逐步告訴您,如何使用 Microsoft Visual Basic.NET 中的通訊端來 ping 網際網路通訊協定 (IP) 位址。[PING 命令會使用網際網路控制訊息通訊協定 (ICMP) 來測試網路連線。回應時間來 ping 特定的 IP 位址是計算和顯示。本文使用 [System.Net.Sockets API 的 Visual Basic.NET 來 ping IP 位址。

需求

本文假設您已熟悉下列主題:
  • 使用 Visual Basic.NET 程式設計
  • 通訊端
下列清單列出建議的硬體、 軟體、 網路基礎結構及您需要的服務套件:
  • Microsoft Windows 2000]、 [Microsoft Windows XP] 或 [Microsoft Windows Server 2003
  • Microsoft Visual Basic.NET

宣告 ICMP 封包結構

ICMP 支援包含錯誤訊息、 控制訊息和資訊訊息的封包。[PING 命令會使用 ICMP 來測試網路連線。使用下列程式碼來宣告 ICMP 封包結構,並宣告一個方法來計算封包中的位元組總數:
   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. 按一下 [專案類型,] 下的 [Visual Basic 專案]。
  4. 在 [範本 下, 按一下 主控台應用程式
  5. 在 [名稱] 方塊中,輸入 MyConsoleApplication

    附註MyConsoleApplication 是範例 Visual Basic.NET 應用程式。
  6. 在 [位置] 方塊中輸入您想要儲存 MyConsoleApplication] 專案的位置,然後按一下 [[確定]

    預設情況下,會建立 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,從 啟動物件 下拉式清單方塊,然後再按一下 [確定]
  11. 在 [偵錯] 功能表上按一下 [開始]。
  12. 在命令提示字元會出現,輸入主機名稱或 IP 位址,並按下 ENTER。

?考

如需詳細資訊請造訪下列 Microsoft 開發人員網路 (MSDN) 網站:
http://msdn2.microsoft.com/en-us/library/system.net.sockets(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/system.net.sockets(vs.71).aspx)

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

http://msdn2.microsoft.com/en-us/library/system.net.sockets.socket(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/system.net.sockets.socket(vs.71).aspx)
如需詳細資訊按一下 [下面的文件編號,檢視 「 Microsoft 知識庫 」 中的發行項]:
300197? (http://support.microsoft.com/kb/300197/ ) 如何: 使用 ICMP Ping 與 Visual Basic 的 IP 位址

這篇文章中的資訊適用於:
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
關鍵字:?
kbmt kbnetwork kbhowtomaster kbwinsock KB828993 KbMtzh
機器翻譯機器翻譯
重要:本文是以 Microsoft 機器翻譯軟體翻譯而成,而非使用人工翻譯而成。Microsoft 同時提供使用者人工翻譯及機器翻譯兩個版本的文章,讓使用者可以依其使用語言使用知識庫中的所有文章。但是,機器翻譯的文章可能不盡完美。這些文章中也可能出現拼字、語意或文法上的錯誤,就像外國人在使用本國語言時可能發生的錯誤。Microsoft 不為內容的翻譯錯誤或客戶對該內容的使用所產生的任何錯誤或損害負責。Microsoft也同時將不斷地就機器翻譯軟體進行更新。
按一下這裡查看此文章的英文版本:828993? (http://support.microsoft.com/kb/828993/en-us/ )
Microsoft及(或)其供應商不就任何在本伺服器上發表的文字資料及其相關圖表資訊的恰當性作任何承諾。所有文字資料及其相關圖表均以「現狀」供應,不負任何擔保責任。Microsoft及(或)其供應商謹此聲明,不負任何對與此資訊有關之擔保責任,包括關於適售性、適用於某一特定用途、權利或不侵權的明示或默示擔保責任。Microsoft及(或)其供應商無論如何不對因或與使用本伺服器上資訊或與資訊的實行有關而引起的契約、過失或其他侵權行為之訴訟中的特別的、間接的、衍生性的損害或任何因使用而喪失所導致的之損害、資料或利潤負任何責任。