Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Ping Xxx.xxx.xxx.XXX (big IP's)


I would like to ping google. When I use MS_DOS it pings just fine, but my program can not ping it for some reason.

CMD PING www.google.com


Code:
Const SOCKET_ERROR = 0
Private Type WSAdata
wVersion As Integer
wHighVersion As Integer
szDescription(0 To 255) As Byte
szSystemStatus(0 To 128) As Byte
iMaxSockets As Integer
iMaxUdpDg As Integer
lpVendorInfo As Long
End Type
Private Type Hostent
h_name As Long
h_aliases As Long
h_addrtype As Integer
h_length As Integer
h_addr_list As Long
End Type
Private Type IP_OPTION_INFORMATION
TTL As Byte
Tos As Byte
Flags As Byte
OptionsSize As Long
OptionsData As String * 128
End Type
Private Type IP_ECHO_REPLY
Address(0 To 3) As Byte
Status As Long
RoundTripTime As Long
DataSize As Integer
Reserved As Integer
data As Long
Options As IP_OPTION_INFORMATION
End Type
Private Declare Function GetHostByName Lib "wsock32.dll" Alias "gethostbyname" (ByVal HostName As String) As Long
Private Declare Function WSAStartup Lib "wsock32.dll" (ByVal wVersionRequired&, lpWSAdata As WSAdata) As Long
Private Declare Function WSACleanup Lib "wsock32.dll" () As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Declare Function IcmpCreateFile Lib "icmp.dll" () As Long
Private Declare Function IcmpCloseHandle Lib "icmp.dll" (ByVal HANDLE As Long) As Boolean
Private Declare Function IcmpSendEcho Lib "ICMP" (ByVal IcmpHandle As Long, ByVal DestAddress As Long, ByVal RequestData As String, ByVal RequestSize As Integer, RequestOptns As IP_OPTION_INFORMATION, ReplyBuffer As IP_ECHO_REPLY, ByVal ReplySize As Long, ByVal TimeOut As Long) As Boolean
Public Function ping(HostName)
'KPD-Team 2000
'URL: [url]http://www.allapi.net/[/url]
'E-Mail: [email]KPDTeam@Allapi.net[/email]
'Const HostName = "www.allapi.net"
Dim hFile As Long, lpWSAdata As WSAdata
Dim hHostent As Hostent, AddrList As Long
Dim Address As Long, rIP As String
Dim OptInfo As IP_OPTION_INFORMATION
Dim EchoReply As IP_ECHO_REPLY
Call WSAStartup(&H101, lpWSAdata)
If GetHostByName(HostName + String(64 - Len(HostName), 0)) <> SOCKET_ERROR Then
CopyMemory hHostent.h_name, ByVal GetHostByName(HostName + String(64 - Len(HostName), 0)), Len(hHostent)
CopyMemory AddrList, ByVal hHostent.h_addr_list, 4
CopyMemory Address, ByVal AddrList, 4
End If
hFile = IcmpCreateFile()
If hFile = 0 Then
MsgBox "Unable to Create File Handle"
Exit Function
End If
OptInfo.TTL = 255
If IcmpSendEcho(hFile, Address, String(32, "A"), 32, OptInfo, EchoReply, Len(EchoReply) + 8, 2000) Then
rIP = CStr(EchoReply.Address(0)) + "." + CStr(EchoReply.Address(1)) + "." + CStr(EchoReply.Address(2)) + "." + CStr(EchoReply.Address(3))
Else
ping = -2
'MsgBox "Timeout"
End If
If EchoReply.Status = 0 Then
'MsgBox "Reply from " + HostName + " (" + rIP + ") recieved after " + Trim$(CStr(EchoReply.RoundTripTime)) + "ms"
ping = Trim$(CStr(EchoReply.RoundTripTime))
Else
ping = -1
'MsgBox "Failure ..."
End If
Call IcmpCloseHandle(hFile)
Call WSACleanup
End Function


Public Function resolveIP(HostName)
'KPD-Team 2000
'URL: [url]http://www.allapi.net/[/url]
'E-Mail: [email]KPDTeam@Allapi.net[/email]
'Const HostName = "www.allapi.net"
Dim hFile As Long, lpWSAdata As WSAdata
Dim hHostent As Hostent, AddrList As Long
Dim Address As Long, rIP As String
Dim OptInfo As IP_OPTION_INFORMATION
Dim EchoReply As IP_ECHO_REPLY
Call WSAStartup(&H101, lpWSAdata)
If GetHostByName(HostName + String(64 - Len(HostName), 0)) <> SOCKET_ERROR Then
CopyMemory hHostent.h_name, ByVal GetHostByName(HostName + String(64 - Len(HostName), 0)), Len(hHostent)
CopyMemory AddrList, ByVal hHostent.h_addr_list, 4
CopyMemory Address, ByVal AddrList, 4
End If
hFile = IcmpCreateFile()
If hFile = 0 Then
MsgBox "Unable to Create File Handle"
Exit Function
End If
OptInfo.TTL = 255
If IcmpSendEcho(hFile, Address, String(32, "A"), 32, OptInfo, EchoReply, Len(EchoReply) + 8, 2000) Then
rIP = CStr(EchoReply.Address(0)) + "." + CStr(EchoReply.Address(1)) + "." + CStr(EchoReply.Address(2)) + "." + CStr(EchoReply.Address(3))
Else
resolveIP = "-1"
'MsgBox "Timeout"
End If
If EchoReply.Status = 0 Then
'MsgBox "Reply from " + HostName + " (" + rIP + ") recieved after " + Trim$(CStr(EchoReply.RoundTripTime)) + "ms"
'ping = Trim$(CStr(EchoReply.RoundTripTime))
Else
resolveIP = "-1"
'MsgBox "Failure ..."
End If
Call IcmpCloseHandle(hFile)
Call WSACleanup

resolveIP = rIP
End Function

For example, Google:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:Documents and SettingsJeff>ping www.google.com

Pinging www.google.akadns.net [64.233.167.99] with 32 bytes of data:

Reply from 64.233.167.99: bytes=32 time=25ms TTL=247
Reply from 64.233.167.99: bytes=32 time=25ms TTL=247
Reply from 64.233.167.99: bytes=32 time=24ms TTL=247
Reply from 64.233.167.99: bytes=32 time=24ms TTL=247

Ping statistics for 64.233.167.99:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 24ms, Maximum = 25ms, Average = 24ms

C:Documents and SettingsJeff>




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Urgent ; Server Cannot Ping To Others And Others Cannot Ping To Server
Server can ping to others and others cannot ping to server??

guys , what could be the possible problem that the server cannot be ping and even outsider cannot ping that server

but the weird thing is that when i use the pcanywhere to login to that server, it still can be done???

why is it like that .... i never came across this before please advise

Ping
Is it Possible to write a program that pings another computer....if so then how?

Hey...how Do I Ping??
how do i ping a url or a ip adress???

10x

Ping...
Help,

I need to Scan a list of several thousand Workstations over a WAN, and check if they are powered up, and if so check if a certain software package is installed...

Checking for the package is easy, just use a Folder or File Exist method, but I need a fast way of checking to see if the Workstation is on line, and not wait for a timeout.

Is it possible to use DNS and IP address or is there other more efficient ways of doing this.

All ideas appreciated.

Thanks.

Ping
I am very new at VB so if you could dumb it down that would be great. I need a program that can ping a specific IP address. And ping it with a certain amount of bytes. I have no idea how to do this and any help would be greatly appreciated.

Ping!
Heres the byproduct of some spare time and the want to learn DX8. I give you Ping! I hope you enjoy. I'll be adding features that make it different from Pong! soon.

Thinker has gotten some errors that I cant reproduce. Please let me know if you get them too. Thanks.

Ping
is it possible to send a "ping" within a programm?

I have used "ping" before by using cmd.exe but this is not realy what i want know.

Thanx for help

Help Me In Ping
Hi I need to run ping on my pc after every 15 min and want to get the results logged and appended in a log file How do I do this please help me

Ping MS
How can I get the amount of time (MilliSeconds) it takes to ping a server?

has ping, but no MS:
http://www.andreavb.com/forum/viewtopic_2780.html

To Ping Or Not To Ping...
Hi!

I maintain a GUI based, "Ping" program that allows end-users to run the Ping.exe utility against multiple nodes and display the results within a text box. The current program version is exclusive to Windows NT 4.0/2000 due to a hardcoded reference to ping.exe.

I'm now trying to re-write the existing hardcoded code so that "Ping" will run any Windows based system that contains system32ping.exe. I thought the quick and easy fix would simply involve pulling the system folder path using an environment reference and then combining the result with "system32" and "ping.exe." This is where I'm running into a jam. I'm sure I'm missing an obvious step, but my brain is near scrambled at this point. :-D

The code (in bold text) I'm trying to re-write exists within the following sub routine:

Code:
Private Sub cmdPink_Click()
cmdClear_Click
If FileName = "" Then
MsgBox "Select a Text file, and Click PING.", _
vbOKOnly, "Error!"
Exit Sub
End If
MousePointer = 11
ReDim sStatus(iLoop) As String
Dim rc As Integer
Dim sFilePing As String
Dim FileNum As Integer
Dim sTemp As String
Dim bGetResult As Boolean
Dim iTotal As Integer
iTotal = iLoop

[b][b]sFilePing = "c:winntsystem32ping.exe "[/b][/b]

[b][b]If Dir(sFilePing) = "" Then
MsgBox "The system can't find ping.exe. Please select it manually.", vbOKOnly, "Error!"
sFilePing = GetFile
End If[/b][/b]

FileNum = FreeFile
bGetResult = False
iLoop = 0
While (iLoop < iTotal)
'While (iLoop < 6)
rc = Shell(Environ$("comspec") & " /c " & sFilePing & _
sMachineName(iLoop) & " > " & sResultFile, 0)
Pause (rc)
Open sResultFile For Input As FileNum
While Not (EOF(FileNum) Or bGetResult)
Input #FileNum, sTemp
If InStr(1, sTemp, "reply from", 1) Then
sStatus(iLoop) = "Active."
bGetResult = True
ElseIf InStr(1, sTemp, "bad ip address", 1) Then
sStatus(iLoop) = "Bad IP Address."
bGetResult = True
ElseIf InStr(1, sTemp, "unknown host", 1) Then
sStatus(iLoop) = "Bad IP Address."
bGetResult = True
ElseIf InStr(1, sTemp, "timed out", 1) Then
sStatus(iLoop) = "Not Active."
bGetResult = True
End If
DoEvents
Wend
Close FileNum

txtResult.Text = txtResult.Text & sMachineName(iLoop) & vbNewLine
'" : " & sstatus(iLoop) & vbNewLine
txtStatus.Text = txtStatus.Text & sStatus(iLoop) & vbNewLine
bGetResult = False
iLoop = iLoop + 1
Label1.Caption = iLoop & " / " & iTotal
Wend

MousePointer = 0
Beep

End Sub

-----------------------------------------------------------------------------------

Here's Writer's version:

Private Sub cmdPink_Click()
cmdClear_Click
If FileName = "" Then
MsgBox "Select a Text file, and Click PING.", _
vbOKOnly, "Error!"
Exit Sub
End If
MousePointer = 11
ReDim sStatus(iLoop) As String
Dim rc As Integer
[b][b]Dim PingPath As String[/b][/b]
Dim sFilePing As String
Dim FileNum As Integer
Dim sTemp As String
Dim bGetResult As Boolean
Dim iTotal As Integer
iTotal = iLoop

[b][b]PingPath = Environ("windir") & "SYSTEM32" & "ping.exe"[/b][/b]
[b][b]sFilePing = PingPath[/b][/b]

FileNum = FreeFile
bGetResult = False
iLoop = 0
While (iLoop < iTotal)
'While (iLoop < 6)
rc = Shell(Environ$("comspec") & " /c " & sFilePing & _
sMachineName(iLoop) & " > " & sResultFile, 0)
Pause (rc)
Open sResultFile For Input As FileNum
While Not (EOF(FileNum) Or bGetResult)
Input #FileNum, sTemp
If InStr(1, sTemp, "reply from", 1) Then
sStatus(iLoop) = "Active."
bGetResult = True
ElseIf InStr(1, sTemp, "bad ip address", 1) Then
sStatus(iLoop) = "Bad IP Address."
bGetResult = True
ElseIf InStr(1, sTemp, "unknown host", 1) Then
sStatus(iLoop) = "Bad IP Address."
bGetResult = True
ElseIf InStr(1, sTemp, "timed out", 1) Then
sStatus(iLoop) = "Not Active."
bGetResult = True
End If
DoEvents
Wend
Close FileNum

txtResult.Text = txtResult.Text & sMachineName(iLoop) & vbNewLine
'" : " & sstatus(iLoop) & vbNewLine
txtStatus.Text = txtStatus.Text & sStatus(iLoop) & vbNewLine
bGetResult = False
iLoop = iLoop + 1
Label1.Caption = iLoop & " / " & iTotal
Wend

MousePointer = 0
Beep

End Sub
----------------------------------------------------------------------------------

Note: I removed the condition check after the SFilePing assignment because I'm mulling over how I want to re-write the condition.

Help... :-)

-Writer-

How Do You Use PING
Does anybody know how to pass arguments to the PING command so it will spool results to a text file, I have tried:


Code:
Shell "ping.exe www.bbc.co.uk > c:myping.txt"
this produces the dos window for an instant and then goes, when I check for the file it is not there. Anybody know why???

Thanks for any help.

It This A Ping?...
i would like to send a message to different user on my network like a popup message(msgbox) is there a way i could do this

i would like to send messages like "don't run the install for the next 10 minutes, i'm compiling it!"

i know this could sound like hacking so i would prefer private messages please

I'll be among the best soon, very soon!!!

Ping
Hi !

I've been writing a program that has a backend db and a frontend user app with db. Both are connected server-client via replication and client-server via MSMQ. I'd like to write a small tool that pings the server from the client, telling me if the server is currently connected or not. I've managed to do this via the IP adress of the server, but it must be possible using the network name of the server. Can it be done ?

Greetz

<font color=green>Do or do not
There is no try</font color=green>

Ping In VB 6.0 (.EXE) App
Hi, I am new to vb programming. I am so new, that I just finished installed VB 6.0 like 2 minutes ago so you now know how much knowledge of programming I have. This is what I need to do. I have a couple of stores that are on a high speed internet connection and I have a vpn link betweeen the stores and my office. Usually I just go to a DOS Prompt and type ping 192.168.10.1 and it either gives me a reply or a time out. Now I want to create a vb program (.exe) so that I can click on a button and if ping's the ip address successfully which is linked to that button I would like a green light next to that store and if it "times out" I want a red light next to that store. I don't expect someone to tell me everything step by step how to acomplish this. All I need to know is how do I get the "button" I created linked with the ping command to the proper IP and if fails I get a little red light and if it reply's I would like a green light.

Thanks for any help in advance.

ScarEye


P.S. Sorry for being a newbie.

How To Ping?
Hey, Im working on a game that is over the internet so i need to know how to ping, but sadly i do not know anything about it. The examples i found at planet-souce-code.com wernt too good so if someone can help a bit itd be great thanks

Ping API
I am currently using GetRTTAndHopCount to do a ping from some VB 6 code. This works, the problem is that it will wait for 4-6 seconds if there is no response.

I am wondering if anyone has an alternet API function to ping an IP address from VB 6.

EDIT: one that does not take so long.

Ping A Ip
i have a button n a textbox

i want to ping a ip

how can i do that??

UDP Ping
Hi all,

How would I ping a UPD port to check for a response??

Thanks,

Ross

Ping
how to get the response-time/ping of a host/ip.
This should be without icmp because that isnt working for the ip's i need to get the ping from.

Ping
How would one go about pinging a computer on a local LAN in vb6?

Ping?
How do you ping in vb? Like i want to ping a user to see if that user is still using the .exe..is it possible?

Ping
Hello!

How can i create a simple ping utility ?

Thanks!

Ping
When i get an ip from a textbox, how could i ping to see if it really a pc or a server on my LAN?

Ping In The VB App
i am having some trouble with the network, how can i ping some ip in my network before i work with the database??

for example:


VB Code:
private function ping(byval ip as string) as boolean  return true if does ping, else return falseend function private sub record()  if ping(192.168.0.1) then    write data on database  else    write data on file  end ifend sub


Thanks for your help,
Guilherme Costa

What Does Mean Ping?
I have heard the word in lots of places. I know that it involves the use of winsock and it has to do something with getting and sending data between computers. But can you tell me

what does "Ping" do?
What is it usefull for?

A Ping In VB
Suppose i have the following sentence:
Ping 192.168.5.2

i want to execute this command without use the SHELL or without using a BATCH FILE. Is there is a way in VB to do so?

How To Ping?
how to ping throu winsock?

Ping!
What i am trying to do is to ping an IP address . Plz if you can help out i really wanna know how its done. Thx for the help.

Ed..

Ping'ing
Is there a quick way to ping an IP address in VB?

Thanks
Darren

Ping Via Vb
Hi.
How can i ping to another computer, and get the result immediately via VB?
Thanks .

RivKin.

Ping A Mac
anyone know how to ping a Mac to see it it's alive

Ping
I've been looking for an easy way to return the results when pinging a computer. I looked at the code at http://www.mvps.org/vbnet/code/network/ping.htm but it looks as if it will only work for IP addresses. I need to ping computer names on a local network (ie. computer01). If anyone has used this code, will it work for me, and/or is there a simpler way to accomplish this?
Thanks in advance.

Ping Using Vb
how do u ping a server with SPECIFIED bytes of data ?

like greater than 32 bytes

Ping
hi
does anyone know a way that when a visitor gos to a webpage it automatically send two pings to different servers and which ever is the fastest is the server they are redirected to.
is this possible in html or something to go in a webpage
thanks

Ping -s ?
What in the name of god does the -s flag actually do ?

Ping?
I need to know 2 things!

1- How do i ping something and find out how long it took?
2- Then how do i divide it by a number??

Please help thanks.

VB Ping Log
Heres a sample of the code I am using:

Private Sub Command1_Click()
Do
Pause 10000 'Loop every 10 seconds
Dim intFileNo As Long
retval = Shell("ping.exe" & " " & Text1.Text, 0)
intFileNo = FreeFile
Open App.Path & "Log.txt" For Append As #intFileNo
Print #intFileNo, "Server Ping Log Starting at: " & Format(Date, "dddd mmmm dd yyyy") & " " & "-" & " " & Format(Time, "hh" & ":" & "mm" & ":" & "ss")
Print #intFileNo, Text1.Text
Close #intFileNo
Loop
End Sub

Cheers!

Ping
i am trying to use the ping command from within VB

when it runs the code, it says that the sub or function ins'n defined.

do i need to add a referance or something?
if so which one?

Ping
How do I send ping packets and then log the results to a text box.
I would use the windows ping, but that runs in a dos window, and I want to be able to view full diagnostic information from inside my program

Thanks

Ping
How to get the results of a ping?..

I mean If I put ping 207.46.130.45 (which is the IP of Microsoft.com) it returns some results..Average response time etc...How to get these values in my VB program. I have seen it somewhere in the forum but don't remember where..

Ping
can anyone tell me how to ping an ip with vb?

thanks

emptywords

How Do I Ping?
I posted ealier asking how to tell a program to search the internet for other computers running the same program and retreive that computers ip address.

someone said I could ping different ip's to find a connection. But how do I do this, how do I ping, and how do I get the ip address the program in pinging to change to that it can perform a sort of search.

Ping
how do you ping an ip address...???

Ping From VB?
How do you send a PING from VB? I did a search on VB world and got a response, however the link to the tip was bad. An help would be appreciated.

Ping
Hi,
Is there a way to check to see if the computer connected and on the network using the computer name? Can this be done using some kind of ping??

Please help!

Ping On VB
hi there

is it possible to capture the values that the ping generate.
i want to build a form with 1 txtbox that contain IP address
,1 button that when the user will click on it ,it will check the communication .

i thought of using the ping app. but i ll b happy to hear
other ideas.

tnx lirlir

How Can I Ping In VB?
i have used the code i found on this site to determine if i'm on line either via lan or modem. The problem is my cable company is crap and my cable modem goes down all the time. I have a complete loss of internet connectivity. But the code in the example isConnected = ViaLan() still returns TRUE even though I have no internet access. I need to use a different method to determine if i'm online. If I knew how to PING in VB that should do the trick.

Thanks!

Ping
Does anybody have a ping code so I can ping my internet every 5 seconds

I Want To PING In VB - Possible ???
or something that comes close to this ....

thank in advance,

Don.

Copyright 2005-08 www.BigResource.com, All rights reserved