Solved

network check

Posted on 2004-03-29
6
171 Views
Last Modified: 2013-11-13
HI experts...
  I am trying to creating an application in visual basic such that if the communication link (LAN Cable) between 2 pc's is not available(broken/removed) then it must trigger a message. I think I might have to use windows API for that but I am not too sure. Can you all please help me? I am really looking forward to your comments.
0
Comment
Question by:Daran_M
  • 2
6 Comments
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 10709572
U can ping the Computer .. and when u dont get an reply trigger an event...

here is a simple ping code for VB ( Thanx to PLG)

Public Function Ping(sAddress As String, _
                     sDataToSend As String, _
                     ECHO As ICMP_ECHO_REPLY) As Long

   Dim hPort As Long
   Dim dwAddress As Long
   
  'convert the address into a long representation
   dwAddress = inet_addr(sAddress)
   
  'if dwAddress is valid
   If dwAddress <> INADDR_NONE Then
   
     'open a port
      hPort = IcmpCreateFile()
     
     'and if successful,
      If hPort Then
     
        'ping it.
         Call IcmpSendEcho(hPort, _
                           dwAddress, _
                           sDataToSend, _
                           Len(sDataToSend), _
                           0, _
                           ECHO, _
                           Len(ECHO), _
                           glngPingTime)

        'return the status as ping success
         Ping = ECHO.status

        'close the port handle
         Call IcmpCloseHandle(hPort)
     
      End If  'If hPort
     
   Else:
   
        'the address format was probably invalid
         Ping = INADDR_NONE
         
   End If
 
End Function
0
 
LVL 1

Expert Comment

by:developer007
ID: 10709833
Yeh..

 Some times the connection is proper and ping may not happen also..


   
0
 

Author Comment

by:Daran_M
ID: 10714446
HI experts,
         thanks for the reply. Isn’t there any API function that can be used to achieve this? thanks once again for the reply.
0
 
LVL 19

Accepted Solution

by:
Melih SARICA earned 50 total points
ID: 10714528
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
This is about my first experience with programming Arduino.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question