Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
What service is running on that port, and what exactly are you trying to test? This makes a world of difference. –  Dan Jan 24 '12 at 11:11
    
@Dan: It's my custom-protocol TCP server. I'm trying to test if client connectivity to the server is not blocked by firewall –  Andy T Jan 24 '12 at 11:13
    
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 –  Dan Jan 24 '12 at 11:15
    
@Dan: added some details to the question –  Andy T Jan 24 '12 at 13:52
    
To clarify, you have a tool that is supposed to diagnose whether a client can connect to the server using a standard tool from the client like Telnet, but when you make the connection it's not made to give a response to indicate or log if the connection was successfully made? –  Bart Silverstrim Jan 24 '12 at 14:10

4 Answers 4

up vote 1 down vote accepted

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

share|improve this answer
    
Must be something downloadable or installable?? –  Chris S Jan 24 '12 at 14:21
    
Yes (can't put the link in till I get to a full web client) –  Jim B Jan 24 '12 at 14:23

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.

share|improve this answer
    
Added details to the question. I'm running it from the server by psexec, I cannot see its blank screen. –  Andy T Jan 24 '12 at 13:59

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|improve this answer
    
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. –  Andy T Jan 24 '12 at 13:58
    
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. –  Bart Silverstrim Jan 24 '12 at 14:09
    
You could try glomming a fix together by having an executable statically compiled into a shared directory and running it from that UNC or shared drive on the client...netcat can make netcat connections to itself. –  Bart Silverstrim Jan 24 '12 at 14:13

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.