ping(IP:Port)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

ping(IP:Port)

06 Oct 2015, 10:26

Search solution for this:

http://www.autohotkey.com/board/topic/8 ... /?p=600371

how can i ping with ports ( ping(IP:Port)
eg.
100.200.300.400:10001 - Ping 32
100.200.300.400:10002 - Ping 30
100.200.300.400:10006 - Ping 36

BTW http://serverfault.com/questions/309357 ... cific-port

BTW i want check if my localhost:80/doSomeProject is available running. if not i want start apace server.

may its easier (workAround) try start it always.

workaround :offtopic: :offtopic: :bravo: :

i check

FreeCommander - DOS - apache_start.bat ahk_class ConsoleWindowClass

Code: Select all

      if(InStr(tc, n1) && InStr(tc, n2) && InStr(tc, n3) )
      {
         apache_start_bat_ahk = apache_start.bat ahk_class ConsoleWindowClass
         SetTitleMatchMode,2
         if( !WinExist( apache_start_bat_ahk ) ) {
            Run ,cmd.exe /k apache_start.bat, X:\xampp568ftp
         }
      }
Last edited by SL5 on 06 Oct 2015, 11:25, edited 3 times in total.
geek
Posts: 1053
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: ping(IP:Port)

06 Oct 2015, 10:32

Ping works via ICMP, which has no concept of ports and has nothing to do with TCP/UDP (which are the protocols generally talked about when referring to ports). What is it you're trying to accomplish by pinging "with ports"?
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: ping(IP:Port)

06 Oct 2015, 10:38

GeekDude wrote:Ping works via ICMP, which has no concept of ports and has nothing to do with TCP/UDP (which are the protocols generally talked about when referring to ports). What is it you're trying to accomplish by pinging "with ports"?
yes its not working.

C :\ldindows\System32>ping localhost: 80
Ping-Anforderung konnte Host "localhost:80" nicht finden. Überpr en, und uersuchen Sie es erneut.
C :\lüindows\System32>ping localhost
Ping ... mit 32 Bytes Daten:
Antwort uon ::1: Zeit<1ms
Antwort uon ::1: Zeit<1ms
Antwort uon ::1: Zeit<1ms
Antwort uon ::1: Zeit<1ms
Ping-Statistik für : : 1 :
Pakete: Gesendet = 4, Empfangen = 4, Uerloren = 0 (0% Uerlust),
Ca. Zeitangaben in Millisek.:
Minimum = 0ms, Maximum = 0ms, Mittelwert = 0ms
lexikos
Posts: 9641
Joined: 30 Sep 2013, 04:07
Contact:

Re: ping(IP:Port)

06 Oct 2015, 20:26

TW i want check if my localhost:80/doSomeProject is available running.
There are at least a couple of options:
1. Attempt a HTTP query. If it succeeds, you know the server is already running.
2. Just check if the Apache service is running (e.g. with sc query command line utility).
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: ping(IP:Port)

07 Oct 2015, 02:57

lexikos wrote:
TW i want check if my localhost:80/doSomeProject is available running.
There are at least a couple of options:
1. Attempt a HTTP query. If it succeeds, you know the server is already running.
2. Just check if the Apache service is running (e.g. with sc query command line utility).
now (07.10.2015 17:04) i started xampp and tried:

Code: Select all

isDevellopperMode=true 
#Include *i init_global.init.inc.ahk

#Include httpQuery.ahk ; https://github.com/camerb/AHKs/blob/master/thirdParty/httpQuery.ahk

Clipboard := A_AhkVersion ; 1.1.22.06

URL := "http://localhost/xampp/"
html := ""
htmlLength := httpQuery(html,URL)
htmlLength_html = '%htmlLength%' = htmlLength `n  '%html%' = html  `n  '%A_AhkVersion%' = A_AhkVersion (line:%A_LineNumber%) `n 
Clipboard := htmlLength_html


#Include *i functions_global.inc.ahk
#Include *i functions_global_dateiende.inc.ahk
#Include *i UPDATEDSCRIPT_global.inc.ahk
=>

'-1' = htmlLength
'' = html
'1.1.22.06' = A_AhkVersion (line:11)

:?:


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

alternativ, follwoing workAround is working. :thumbup: . but o dont need to download / rad complete file. may there is a shorter/faster method?

Code: Select all

isDevellopperMode=true 
#Include *i init_global.init.inc.ahk

URL := "http://localhost/xampp/index.php"

; Example: Download text to a variable:
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", URL , true)
whr.Send()
; Using 'true' above and the call below allows the script to remain responsive.
whr.WaitForResponse()
whr_ResponseText := whr.ResponseText
;~ MsgBox % whr_ResponseText 

infoMsg = '%whr_ResponseText%' = whr_ResponseText   `n  '%html%' = html  `n  '%A_AhkVersion%' = A_AhkVersion (line:%A_LineNumber%) `n 
Clipboard := infoMsg
ToolTip, % infoMsg
Sleep,6000

#Include *i functions_global.inc.ahk
#Include *i functions_global_dateiende.inc.ahk
#Include *i UPDATEDSCRIPT_global.inc.ahk
Last edited by SL5 on 07 Oct 2015, 10:21, edited 4 times in total.
User avatar
trismarck
Posts: 506
Joined: 30 Sep 2013, 01:48
Location: Poland

Re: ping(IP:Port)

07 Oct 2015, 08:02

GeekDude wrote:Ping works via ICMP, which has no concept of ports and has nothing to do with TCP/UDP (which are the protocols generally talked about when referring to ports). What is it you're trying to accomplish by pinging "with ports"?
To expand on that:
  • only some of the protocols that work over Network Layer protocols 'have the concept of' ports. Examples would be: TCP and UDP.
  • ICMP is considered a Network Layer protocol (vs a Transport Layer protocol, like TCP and UDP). This is probably because ICMP, unlike TCP and UDP, wasn't designed to transport 'custom' data, but instead to only carry specific control messages (update: and those messages not being 'custom data' but instead only messages related to the Network Layer stuff). On the other hand, ICMP, just like TCP and UDP uses the Network Layer protocol (~think the IP protocol) to route itself over the network. So from the segment/packet 'encapsulation' point of view, ICMP _is_ like TCP and UDP: ICMP (layer 3) uses IP (layer 3), TCP (layer 4) uses IP (layer 3) and UDP (layer 4) uses IP (layer 3) to route itself over the network.
  • All three of ICMP, TCP and UDP use a lower level Network Layer (~OSI) protocol to route themselves over the network. In most cases, that lower level Network Layer protocol is the IP protocol, which encapsulates headers (and the payload, if it's there) of the three. The 'ping' command on Windows pings through ICMP. Nmap can additionally ping through UDP, TCP and others. The definition of a 'ping' can vary depending the protocol (and contents of the PDU for that protocol) one uses to ping 'stuff', i.e. by using ARP to 'ping' hosts on the local network or HTTP to see if the HTTP server responds to HTTP requests or ICMP to see if the host responds to the ICMP Echo Request control message (~host is up). HTTP works over TCP in most cases.
SL5 wrote:100.200.300.400:10001 - Ping 32
100.200.300.400 isn't a valid IPv4 address.
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: ping(IP:Port)

07 Oct 2015, 11:26

this works. if you know it shorter faster, please let me know. thanks

Code: Select all

isDevellopperMode=true 
#Include *i init_global.init.inc.ahk

URL := "http://localhost/xampp/"
isUrlAvailable:=isUrlAvailable(URL)

isUrlAvailable(URL){
   isUrlAvailable:=true
   try{
      whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
      whr.Open("GET", URL , true)
      whr.Send()
      whr.WaitForResponse()
      ;~ whr_ResponseText := whr.ResponseText
   } catch e
   {
      isExceptionThrown:=true
      ;~ MsgBox, An exception was thrown!`nSpecifically: %e%
   }
   if(ErrorLevel || isExceptionThrown)
   {
      isUrlAvailable:=false
   }
   if(true){
      infoMsg = '%isUrlAvailable%' = isUrlAvailable  `n '%isExceptionthrown%' = isExceptionThrown `n  '%whr_ResponseText%' = whr_ResponseText   `n `n `n `n '%ErrorLevel%' = ErrorLevel `n   '%html%' = html  `n  '%A_AhkVersion%' = A_AhkVersion '%whr%' = whr (line:%A_LineNumber%) `n `n '%whr_status%' = whr_status
      ToolTip, % infoMsg
      Sleep,6000
   }
   return isUrlAvailable
}


#Include *i functions_global.inc.ahk
#Include *i functions_global_dateiende.inc.ahk
#Include *i UPDATEDSCRIPT_global.inc.ahk
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: ping(IP:Port)

07 Oct 2015, 12:22

trismarck wrote:100.200.300.400 isn't a valid IPv4 address.
It was just an example of my post he linked...

Xfire was a proprietary freeware instant messaging service for gamers that also served as a game server browser with various other features.

If you added game IP's where multiple server has the same IP but just a different Port, he gave us the pings to every Server.

e.g.

Code: Select all

Server A: 192.168.0.1:10001   => Ping: 32
Server B: 192.168.0.1:10002   => Ping: 30
Server C: 192.168.0.1:10003   => Ping: 36
How does Xfire reports different Pings for the same IPs based on its Ports?
As you can see here => 4 Servers with same IP but different Ports and 4 different Pings
Image
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
trismarck
Posts: 506
Joined: 30 Sep 2013, 01:48
Location: Poland

Re: ping(IP:Port)

07 Oct 2015, 16:27

jNizM wrote:
trismarck wrote:100.200.300.400 isn't a valid IPv4 address.
It was just an example of my post he linked...
Ok.
Interestingly on Windows, 100.200.300.400 is not considered a domain name, but _is_ considered a NetBIOS name, just like aaaaa-bbbbbb.
jNizM wrote:How does Xfire reports different Pings for the same IPs based on its Ports?
Some thoughts on that:
  • Xfire could just use ICMP, discard the port information (as there is no 'port' field in the ICMP header) and ping the same host each time. Differences in pings would then be the same differences that occur when one pings a casual internet domain name, like google.com (update: I guess this is false bc there could be load-balancers behind the domain name, but I'm too dumb for that; for simplicity, assume there is just one simple server behind that domain name). The ICMP method seems unlikely, as the ping time on a local network, especially over a cable, would be faster than 30ms.
  • Xfire could also use some other way of 'pinging' the servers, like sending a TCP ACK or SYN segment on given port and waiting for the response. Or it could send some encrypted chunk of data, over a proprietary protocol above TCP (or UDP).
Ping measures round-trip time, so the time is essentially: [part of] the time required to send the PDU + the time PDU travers + the time the PDU is processed and sent back + the time the PDU travels back + [part of] the time to process the received PDU.

One note about the setup would be that because the IP address of all of the servers is the same, unless there is some sort of port-forwarding set up, all of those servers seem to run on _one_ physical machine. If all servers run on one machine, the pings won't be that different (what is pinged is effectively _the same_ machine) unless the server behind the port is implemented in such a way that it i.e. hangs for certain periods of time if there are too many users (or something similar happens).
If there is a way to ping the servers from the lobby by a press of a button, perhaps one could track what exact PDUs are used to ping the servers, i.e. with Wireshark.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: sachalamp and 215 guests