how to check connectivity to server by windows tools?

41,795

Solution 1

Try portqry , the Microsoft command line port scanner. This will tell you what ports you can connect to from a system

Solution 2

If telnet hostname port results in a blank screen with a cursor in the top-left corner, you are connected.

No further tools are necessary.

Solution 3

Here is a VBScript TCP Ping solution I came up with using the MSXML2 ServerXMLHTTP control to test tcp connectivity to a port. It should work on most systems without any additional downloads.

address = "www.example.com"
WScript.Echo "http: " & TCPPing( address, 80)
WScript.Echo "ssh: " & TCPPing( address, 22)
WScript.Echo "smb: " & TCPPing( address, 139)
WScript.Echo "https: " & TCPPing( address, 443)

Function TCPPing( address, port )
  Set xhr = WScript.CreateObject("MSXML2.ServerXMLHTTP")
  xhr.SetTimeouts 8000,8000,8000,8000
  On Error Resume Next
  xhr.Open "GET", "http://" & address & ":" & port, False
  xhr.Send
  Select Case Err.Number
    ' ok, tcp connect but no web response, 401 auth failure
    Case 0,  -2147012744, -2147024891
      msg = "OK"
    Case -2147012867
      msg = "Connection Rejected"
    Case -2147012894
      msg = "Timed out"
    Case -2147012889
      msg = "Could not resolve address"
    Case -2147467259
      msg = "Cannot test that port with this tool"
    Case Else
      msg = "Unknown error " & Err.Number
  End Select
  On Error Goto 0
  Set xhr = Nothing
  TCPPing = msg
End Function

Solution 4

If you're testing firewalls blocking the port, instead of your custom application run netcat on the server machine on that port in question, then connect to it from the client and netcat will let you see the results. That will tell you if the port is blocked or not and not throw in variables regarding your application's functionality.

Share:
41,795

Related videos on Youtube

Andriy Tylychko
Author by

Andriy Tylychko

multiplayer games, multithreading, networking, distributed programming, multimedia streaming C++ http://www.linkedin.com/in/andriytylychko works for Epic Games UK

Updated on September 18, 2022

Comments

  • Andriy Tylychko
    Andriy Tylychko over 1 year

    I need to check if client can connect to server on specific TCP port. Server is listening on it. Tried "telnet server_IP port" but telnet is stuck when I see that it's connected to the server. Seems telnet waits for specific reply from the server.

    What I need is just to check if I can connect to the server from this workstation. Is there any way to do this? I would prefer Windows tools like telnet or something else.

    EDIT: The main goal is to check that particular workstation can reach the server on this port. It's a part of a diagnostic tool. This tool is a simple script being run from the server to diagnos different aspects of this client/server system. It takes workstation name and checks if it's possible to connect to the server from this workstation. I'd like to check connectivity by a standard tool like telnet or anything else from Microsoft, preferably it should be already installed on workstation. I plan to run it by psexec from Sysinternals on workstation and receive the result on the server.

    • Dan
      Dan over 12 years
      What service is running on that port, and what exactly are you trying to test? This makes a world of difference.
    • Andriy Tylychko
      Andriy Tylychko over 12 years
      @Dan: It's my custom-protocol TCP server. I'm trying to test if client connectivity to the server is not blocked by firewall
    • Dan
      Dan over 12 years
      Hang on, you mean you've written an application that listens on a port? So why not use the client to test, or get it to respond to Telnet. You're going to have to connect to that port to prove anything, and the only way to do that is to connect with something that understands what its connecting to
    • Andriy Tylychko
      Andriy Tylychko over 12 years
      @Dan: added some details to the question
    • Andriy Tylychko
      Andriy Tylychko over 12 years
      @BartSilverstrim: :) of course I need to know that connection was established succesfully, but this doesn't mean I need to send/receive any additional data except standard TCP handshake, just to avoid modification of the server code.
  • Andriy Tylychko
    Andriy Tylychko over 12 years
    Tnx for the answer. Added details to the question. Server is running so the port is occupied. It's fine just to connect and immediately disconnect. Also I cannot check connectivity by my client app, that's why I'm looking for something like telnet.
  • Andriy Tylychko
    Andriy Tylychko over 12 years
    Added details to the question. I'm running it from the server by psexec, I cannot see its blank screen.
  • user1364702
    user1364702 over 12 years
    You don't need anything but telnet on the client to connect to netcat on the server, but you would have to close down your application for a few moments to run with netcat. If your application isn't able to spit out a diagnostic code or reply to telnet, then you're going to get a blank screen with a cursor in the corner and not know if it's really talking to your application or if there's a connection issue.
  • Philip
    Philip over 12 years
    Must be something downloadable or installable??
  • raja
    raja over 12 years
    Yes (can't put the link in till I get to a full web client)
  • hibbelig
    hibbelig over 8 years
    I like this one because it can be used without admin rights, even if telnet is turned off.
  • Joshua Drake
    Joshua Drake about 8 years
    Also, one may need to enable telnet first.
  • i336_
    i336_ over 5 years
    This is awesome. If you are looking for something netcat-like but specifically just to answer the edge case question of "is this listening", this is very probably the swiss army knife you are looking for. Tool itself is undated, but winzip self-extractor is dated 1997. The readme file just points to this URL <-- stop and give that a quick look
  • raja
    raja over 5 years
    @i336_ oh it's ancient. Nowadays I'd probably just use powershell like: $Socket = New-Object Net.Sockets.TcpClient; $ErrorActionPreference = 'SilentlyContinue'; $Socket.Connect($Computer, $Port)